Resources and Internationalization

Resources are external files (that is, non-code files) that are used by your code and compiled into your application at build time. Android supports a number of different kinds of resource files, including XML, PNG, and JPEG files. The XML files have very different formats depending on what they describe. This document describes what kinds of files are supported, and the syntax or format of each.

리소스는 외부 파일(즉, 비코드(non-code) 파일)이다. 그것은 여러분의 코드에서 사용되며, 빌드 시점에 여러분의 애플리케이션안으로 컴파일된다. 안드로이드는 XML, PNG, 그리고 JPEG 파일들을 포함하는 많은 다른 종류의 리소스 파일을 지원한다. XML 파일들은 그것들이 설명하고자 하는 것에 따라 매우 다른 포맷들을 가진다. 이 문서는 지원되는 파일의 종류가 무엇인지, 그리고 각각의 구문과 포맷을 설명한다.

Resources are externalized from source code, and XML files are compiled into a binary, fast loading format for efficiency reasons. Strings, likewise, are compressed into a more efficient storage form. It is for these reasons that we have these different resource types in the Android platform.

리소스는 소스 코드 외부에 존재하며, 그리고 그 안의 XML 파일은 효율성을 위해 빠른 로딩loading 포맷인 바이너리로 컴파일된다. 문자열 역시 마찬가지로 효율적인 저장 형태로 압축된다. 이것이 우리가 안드로이드 플랫폼 내에 이와 같이 다른 타입의 리소스를 가지는 이유이다.

This is a fairly technically dense document, and together with the Available Resources document, they cover a lot of information about resources. It is not necessary to know this document by heart to use Android, but rather to know that the information is here when you need it.

이것은 상당히 기술적으로 빽빽한 문서이며, “사용가능한 리소스 타입 문서”와 함께 리소스에 대한 많은 정보를 다룬다. 안드로이드를 사용하기 위해 이 문서를 암기해서 알고 있을 필요는 없으나, 여러분이 그것을 필요로 할 때 그 정보가 여기에 있다는 것을 알아야 한다.

Introduction

This topic includes a terminology list associated with resources, and a series of examples of using resources in code. For a complete guide to the supported Android resource types, see Available Resources.

이 토픽은 리소스와 관련된 용어 리스트와, 그리고 코드에서 리소스를 사용하는 일련의 예제들을 포함한다. 지원되는 안드로이드 리소스 타입에 대한 완전한 가이드를 위해서는, 이후에 나오는 사용가능한 리소스를 보라.

The Android resource system keeps track of all non-code assets associated with an application. You use the Resources class to access your application's resources; the Resources instance associated with your application can generally be found through Context.getResources().

안드로이드 리소스 시스템은 애플리케이션과 관련된 모든 비코드non-code 에셋asset 정보를 유지한다. 여러분의 애플리케이션의 리소스에 접근하기 위해, 여러분은 리소스Resources 클래스를 사용한다. 여러분의 애플리케이션과 관련된 리소스 인스턴스는 Context.getResources()를 통해 일반적으로 찾아내어 진다.

An application's resources are compiled into the application binary at build time for you by the build system. To use a resource, you must install it correctly in the source tree and build your application. As part of the build process, symbols for each of the resources are generated that you can use in your source code -- this allows the compiler to verify that your application code matches up with the resources you defined.

애플리케이션의 리소스는 빌드 시점에 빌드 시스템에 의해 여러분을 위해 애플리케이션 바이너리로 컴파일된다. 여러분은 리소스를 사용하기 위해 소스 트리에 정확하게 그것을 설치하고 애플리케이션을 빌드해야 한다. 빌드 과정의 일부로써 여러분이 소스코드에서 사용할 수 있는 각각의 리소스에 대한 심볼들이 만들어진다. 이것은 여러분의 애플리케이션 코드가 여러분이 정의한 리소스와 일치하는 것을 컴파일러로 하여금 검증하는verify 것을 가능하게 한다.

The rest of this section is organized as a tutorial on how to use resources in an application.

이 섹션의 나머지는 애플리케이션에서 리소스를 사용하는 방법에 관한 튜토리얼로 구성되어 진다.

Creating Resources

Android supports string, bitmap, and many other types of resource. The syntax and format of each, and where they're stored, depends upon the type of object. In general, though, you create resources from three types of files: XML files (everything but bitmaps and raw), bitmap files(for images) and Raw files (anything else, for example sound files, etc.). In fact, there are two different types of XML file as well, those that get compiled as-is into the package, and those that are used to generate resources by aapt. Here is a list of each resource type, the format of the file, a description of the file, and details of any XML files.

안드로이드는 문자열, 비트맵 그리고 많은 다른 타입의 리소스를 지원한다. 각각의 구문과 포맷, 그리고 그것들이 저장되어져 있는 곳은 오브젝트의 타입에 의존한다. 그럼에도 불구하고, 일반적으로 여러분은 세 가지 타입의 파일로부터 리소스를 만든다. XML 파일(비트맵과 원시 파일이 아닌 모든 것), 비트맵 파일(이미지를 위한 것), 그리고 원시raw 파일(그 밖의 것들로, 예를 들어 사운드 파일과 기타)이 그것이다. 실제로는 두 가지의 다른 타입의 XML이 또한 존재한다. 현재 그대로 패키지로 컴파일되는 것과, 그리고 aapt에 의해 리소스를 생성하기 위해 사용되는 것이 있다. 여기 각 리소스 타입의 리스트, 파일의 포맷, 파일의 설명, 그리고 임의의 XML 파일에 대한 상세 사항이 있다.

You will create and store your resource files under the appropriate subdirectory under the res/ directory in your project. Android has a resource compiler (aapt) that compiles resources according to which subfolder they are in, and the format of the file. Table 1 shows a list of the file types for each resource. See the Available Resources for descriptions of each type of object, the syntax, and the format or syntax of the containing file.

여러분은 프로젝트에 있는 res/ 디렉토리 아래에 있는 적절한 하위 디렉토리 아래에 여러분의 리소스 파일을 만들고 저장할 것이다. 안드로이드는 리소스들이 위치하는 하위 폴더와 파일의 포맷에 따라 그것들을 컴파일하는 리소스 컴파일러(aapt)를 가지고 있다. 테이블 1은 각각의 리소스에 대한 파일 타입 리스트를 보여준다. 각각의 오브젝트 타입, 구문, 그리고 포맷 또는 포함하고 있는 파일의 구문에 대한 설명에 대해서는 이후에 나오는 “사용가능한 리소스 타입”을 보라.

Table 1

Table 1

Directory Resource Types
res/anim/ XML files that are compiled into frame by frame animation or tweened animation objects
res/drawable/

.png, .9.png, .jpg files that are compiled into the following Drawable resource subtypes:

To get a resource of this type, use mContext.getResources().getDrawable(R.drawable.imageId)

Note: Image resources placed in here may be automatically optimized with lossless image compression by the aapt tool. For example, a true-color PNG that does not require more than 256 colors may be converted to an 8-bit PNG with a color palette. This will result in an image of equal quality but which requires less memory. So be aware that the image binaries placed in this directory can change during the build. If you plan on reading an image as a bit stream in order to convert it to a bitmap, put your images in the res/raw/ folder instead, where they will not be optimized.

res/layout/ XML files that are compiled into screen layouts (or part of a screen). See Declaring Layout.
res/values/

XML files that can be compiled into many kinds of resource.

Note: Unlike the other res/ folders, this one can hold any number of files that hold descriptions of resources to create rather than the resources themselves. The XML element types control where these resources are placed under the R class.

While the files can be named anything, these are the typical files in this folder (the convention is to name the file after the type of elements defined within):

  • arrays.xml to define arrays
  • colors.xml to define color drawables and color string values. Use Resources.getDrawable() and Resources.getColor(), respectively, to get these resources.
  • dimens.xml to define dimension value. Use Resources.getDimension() to get these resources.
  • strings.xml to define string values (use either Resources.getString or preferably Resources.getText() to get these resources. getText() will retain any rich text styling which is usually desirable for UI strings.
  • styles.xml to define style objects.
res/xml/ Arbitrary XML files that are compiled and can be read at run time by calling Resources.getXML().
res/raw/ Arbitrary files to copy directly to the device. They are added uncompiled to the compressed file that your application build produces. To use these resources in your application, call Resources.openRawResource() with the resource ID, which is R.raw.somefilename.

Resources are compiled into the final APK file. Android creates a wrapper class, called R, that you can use to refer to these resources in your code. R contains subclasses named according to the path and file name of the source file

리소스는 최종적인 APK 파일내로 컴파일된다. 안드로이드는 여러분이 코드에서 이 리소스들을 레퍼런스하기 위해 사용할 수 있는 R이라 불리는 래퍼wrapper 클래스를 생성한다. R은 소스 파일의 경로와 이름에 따라 이름지어진 서브클래스를 포함한다.

Global Resource Notes

  • Several resources allow you to define colors. Android accepts color values written in various web-style formats -- a hexadecimal constant in any of the following forms: #RGB, #ARGB, #RRGGBB, #AARRGGBB.
  • All color values support setting an alpha channel value, where the first two hexadecimal numbers specify the transparency. Zero in the alpha channel means transparent. The default value is opaque.
  • 몇몇 리소스들은 여러분으로 하여금 컬러를 정의할 수 있게 한다. 안드로이드는 다양한 웹 스타일 포맷들로 작성되는 컬러 값을 수용한다 ? 다음과 같은 임의의 형식의 16진수 상수: #RGB, #ARGB, #RRGGBB, #AARRGGBB가 그것이다.
  • 모든 컬러 값은 알파채널 값 설정을 지원하며, 컬러 값의 첫번째 2개의 16진수는 투명도를 나타낸다. 알파 채널이 0인 것은 투명을 의미한다. 디폴트 값은 불투명이다.

Using Resources

This section describes how to use the resources you've created. It includes the following topics:

이 섹션은 여러분이 만들었던 리소스를 사용하는 방법을 설명한다. 그것은 다음과 같은 토픽을 포함한다:

  • 코드 안에서 리소스 사용하기 ? 여러분의 코드에서 리소스를 인스턴스화하기 위해 그것을 호출하는 방법.
  • 다른 리소스에서 리소스 레퍼런스 하기 - 여러분은 다른 리소스에서 리소스를 레퍼런스할 수 있다. 이것은 여러분으로 하여금 리소스에서 일반적인 리소스 값을 재사용하는 것을 가능하게 한다.
  • 택일적alternate 설정을 위한 택일적 리소스 지원하기 ? 여러분은 호스트 하드웨어의 언어 또는 디스플레이 설정에 의존해서 다른 리소스가 로드load되도록 지정할 수 있다.

At compile time, Android generates a class named R that contains resource identifiers to all the resources in your program. This class contains several subclasses, one for each type of resource supported by Android, and for which you provided a resource file. Each class contains one or more identifiers for the compiled resources, that you use in your code to load the resource. Here is a small resource file that contains string, layout (screens or parts of screens), and image resources.

컴파일 시점에, 안드로이드는 여러분의 프로그램에 있는 모든 리소스에 대한 리소스 식별자identifier를 포함하는 R 이라는 이름의 클래스를 생성한다. 이 클래스는 안드로이드가 지원하는 리소스의 각 타입에 따른 하나씩의 서브클래스를 포함하며, 여러분은 각 서브클래스를 위해 하나의 리소스 파일을 제공했었다. 각각의 클래스는 컴파일된 리소스에 대해 하나 또는 그 이상의 식별자identifier를 포함하며, 이것은 여러분이 코드에 그 리소스를 로드하기 위해 사용된다. 아래에 문자열, 레이아웃(스크린 혹은 스크린의 부분), 그리고 이미지 리소스를 포함하는 작은 리소스 파일이 있다.

Note: the R class is an auto-generated file and is not designed to be edited by hand. It will be automatically re-created as needed when the resources are updated.

Note: R 클래스는 자동으로 생성되는 파일이며, 손으로 편집하기 위해 설계된 것이 아니다. 그것은 리소스가 업데이트됐을 때, 필요에 따라서 자동으로 새로 만들어질 것이다.

package com.android.samples;
public final class R {
    public static final class string {
        public static final int greeting=0x0204000e;
        public static final int start_button_text=0x02040001;
        public static final int submit_button_text=0x02040008;
        public static final int main_screen_title=0x0204000a;
    };
    public static final class layout {
        public static final int start_screen=0x02070000;
        public static final int new_user_pane=0x02070001;
        public static final int select_user_list=0x02070002;

    };
    public static final class drawable {
        public static final int company_logo=0x02020005;
        public static final int smiling_cat=0x02020006;
        public static final int yellow_fade_background=0x02020007;
        public static final int stretch_button_1=0x02020008;

    };
};

Using Resources in Code

Using resources in code is just a matter of knowing the full resource ID and what type of object your resource has been compiled into. Here is the syntax for referring to a resource:

코드에서 리소스를 사용하는 것은, 단지 정확한 리소스 ID와 여러분의 리소스가 컴파일된 오브젝트의 타입을 아는 문제이다. 여기에 리소스를 레퍼런스하는 것에 대한 구문이 있다.

R.resource_type.resource_name

R.resource_type.resource_name

or

또는

android.R.resource_type.resource_name

android.R.resource_type.resource_name

Where resource_type is the R subclass that holds a specific type of resource. resource_name is the name attribute for resources defined in XML files, or the file name (without the extension) for resources defined by other file types. Each type of resource will be added to a specific R subclass, depending on the type of resource it is; to learn which R subclass hosts your compiled resource type, consult the Available Resources document. Resources compiled by your own application can be referred to without a package name (simply as R.resource_type.resource_name). Android contains a number of standard resources, such as screen styles and button backgrounds. To refer to these in code, you must qualify them with android, as in android.R.drawable.button_background.

위의 구문에서 resource_type은 리소스의 특정 타입을 보유하는 R의 서브클래스이다. resource_name는 XML 파일에서 정의된 리소스에 대한 name 애트리뷰트이거나, 또는 다른 파일 타입에 의해 정의된 리소스에 대한 파일 이름(확장자 없이) 이다. 리소스의 각 타입은 리소스의 타입에 따라서 R의 특정 서브클래스에 추가될 것이다. R의 어떤 서브클래스가 여러분의 컴파일된 리소스 타입을 보유하는가를 배우기 위해서는, 사용가능한 리소스 문서를 참조하라. 여러분 자신의 애플리케이션에 의해 컴파일된 리소스는 패키지 이름 없이(단순히 R.resource_type.resource_name으로) 레퍼런스될 수 있다. 안드로이드는 스크린 스타일과 버튼 백그라운드와 같은, 다수의 표준 리소스를 포함한다. 코드에서 이것을 레퍼런스하기 위해서, 여러분은 android.R.drawable.button_background에서와 같이 그것이 android를 가지도록 제약해야 한다.

Here are some good and bad examples of using compiled resources in code:

여기에 코드에서 컴파일된 리소스를 사용하는 몇 가지의 좋고 나쁜 예제가 있다.

// Load a background for the current screen from a drawable resource.
this.getWindow().setBackgroundDrawableResource(R.drawable.my_background_image);

// WRONG Sending a string resource reference into a 
// method that expects a string.
this.getWindow().setTitle(R.string.main_title);

// RIGHT Need to get the title from the Resources wrapper.
this.getWindow().setTitle(Resources.getText(R.string.main_title));

// Load a custom layout for the current screen.
setContentView(R.layout.main_screen);

// Set a slide in animation for a ViewFlipper object.
mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, 
        R.anim.hyperspace_in));

// Set the text on a TextView object.
TextView msgTextView = (TextView)findViewByID(R.id.msg);
msgTextView.setText(R.string.hello_message); 

References to Resources

A value supplied in an attribute (or resource) can also be a reference to a resource. This is often used in layout files to supply strings (so they can be localized) and images (which exist in another file), though a reference can be any resource type including colors and integers.

애트리뷰트 (또는 리소스)로 제공되는 값 또한 리소스로 레퍼런스될 수 있다. 어떤 레퍼런스는 컬러와 정수integer를 포함하는 어떤 리소스 타입이 될 수도 있지만, 이것은 흔히 레이아웃 파일 안에 문자열(문자열이 로컬라이즈 될 수 있도록 하기 위해)과 (다른 파일에 존재하는) 이미지를 공급하기 위해 사용된다.

For example, if we have color resources, we can write a layout file that sets the text color size to be the value contained in one of those resources:

예를 들어 만약 우리가 컬러 리소스를 가지고 있다면, 우리는 레이아웃 파일의 텍스트 컬러가 그러한 리소스 중 하나의 값으로 설정되도록 작성할 수 있다.

<?xml version="1.0" encoding="utf-8"?>
<EditText id="text"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:textColor="@color/opaque_red"
    android:text="Hello, World!" />

Note here the use of the '@' prefix to introduce a resource reference -- the text following that is the name of a resource in the form of @[package:]type/name. In this case we didn't need to specify the package because we are referencing a resource in our own package. To reference a system resource, you would need to write:

여기에서 리소스 레퍼런스를 나타내기 위해 “@” 접두어를 사용하는 것에 주의하라 ? 그 뒤에 붙어있는 텍스트는 @[package:]type/name의 형식의 리소스 이름이다. 위의 경우에서 우리는 패키지를 지정할 필요가 없다. 왜냐하면 리소스가 우리 자신의 패키지에 있는 리소스를 레퍼런스하기 때문이다. 시스템 리소스를 레퍼런스하기 위해서는 패키지 이름을 써야 할 필요가 있을 것이다.

<?xml version="1.0" encoding="utf-8"?>
<EditText id="text"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:textColor="@android:color/opaque_red"
    android:text="Hello, World!" />

As another example, you should always use resource references when supplying strings in a layout file so that they can be localized:

다른 예제로, 여러분은 레이아웃 파일에 문자열을 공급할 때 그 문자열이 로컬라이즈될localized 수 있도록 항상 리소스 레퍼런스를 사용해야 한다.

<?xml version="1.0" encoding="utf-8"?>
<EditText id="text"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:textColor="@android:color/opaque_red"
    android:text="@string/hello_world" />

This facility can also be used to create references between resources. For example, we can create new drawable resources that are aliases for existing images:

이 설비facility는 또한 리소스들간의 레퍼런스를 생성하기 위해 이용될 수도 있다. 예를 들어 우리는 이미 존재하는 이미지에 대한 앨리어스alias인 새로운 드로어블drawable 리소스를 생성할 수 있다.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <drawable id="my_background">@android:drawable/theme2_background</drawable>
</resources>

References to Theme Attributes

Another kind of resource value allows you to reference the value of an attribute in the current theme. This attribute reference can only be used in style resources and XML attributes; it allows you to customize the look of UI elements by changing them to standard variations supplied by the current theme, instead of supplying more concrete values.

또 다른 종류의 리소스 값은 여러분으로 하여금 현재 테마의 애트리뷰트의 값을 레퍼런스하는 것을 허용한다. 이 애트리뷰트 레퍼런스는 스타일 리소스와 XML 애트리뷰트에서만 사용될 수 있다. 그것은 여러분이 구체적인 값을 제공하는 대신, 현재 테마에 의해 공급되는 표준 변이variation들로 그것을 변경함으로써 UI 엘리먼트의 모습를 커스터마이즈하는 것을 허용한다.

As an example, we can use this in our layout to set the text color to one of the standard colors defined in the base system theme:

하나의 예제로, 우리의 레이아웃 안에 기본적인 시스템 테마에서 정의된 표준 컬러중 하나로 텍스트 컬러를 지정하기 위해, 우리는 테마 애트리뷰트를 사용할 수 있다.

<?xml version="1.0" encoding="utf-8"?>
<EditText id="text"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:textColor="?android:textDisabledColor"
    android:text="@string/hello_world" />

Note that this is very similar to a resource reference, except we are using an '?' prefix instead of '@'. When you use this markup, you are supplying the name of an attribute resource that will be looked up in the theme -- because the resource tool knows that an attribute resource is expected, you do not need to explicitly state the type (which would be ?android:attr/android:textDisabledColor).

이것은 ‘@’ 대신 “?” 접두어를 우리가 사용한다는 것을 제외하고는 리소스 레퍼런스와 매우 유사하는 것에 주의하라. 여러분이 이 마크업markup을 사용할 때, 여러분은 테마에서 찾을 애트리뷰트 리소스의 name을 공급한다 ? 왜냐하면 리소스 도구가 예상되는 애트리뷰트 리소스를 알기 때문에, 여러분은 명시적으로 그 타입(?android:attr/android:textDisabledColor가 되도록)을 기술할 필요는 없다.

Other than using this resource identifier to find the value in the theme instead of raw resources, the name syntax is identical to the '@' format: ?[namespace:]type/name with the type here being optional.

자체raw 리소스 대신, 테마에서 값을 찾기 위해 이 리소스 식별자Identifier를 사용한다는 것이외에, 그 name 구문은 “@” 포맷과 동일하다: - 여기에서 ?[namespace:]type/name이 type을 가지는 것은 선택 사항이다.

Using System Resources

Many resources included with the system are available to applications. All such resources are defined under the class "android.R". For example, you can display the standard application icon in a screen with the following code:

시스템에 포함된 많은 리소스는 애플리케이션에서도 사용가능하다. 그런 리소스 전부는 “android.R” 클래스 안에 정의되어 있다. 예를 들어 여러분은 아래의 코드를 사용해서 스크린에 표준 애플리케이션 아이콘을 표시할 수 있다. (역주: 아래의 코드 중 requestScreenFeatures()와 setBadgeResource()는 현재 사용되는 않는 메쏘드임.)

public class MyActivity extends Activity
{
    public void onStart() 
    {
        requestScreenFeatures(FEATURE_BADGE_IMAGE);

        super.onStart();

        setBadgeResource(android.R.drawable.sym_def_app_icon);
    }
}

In a similar way, this code will apply to your screen the standard "green background" visual treatment defined by the system:

유사한 방법으로, 아래의 코드는 시스템에 의해 정의된 표준 “초록색(green) 백그라운드” 시각적 효과를 여러분의 스크린에 적용할 것이다.(역주: 아래의 테마는 green 테마가 아니라 black 테마임)

public class MyActivity extends Activity
{
    public void onStart() 
    {
        super.onStart();

        setTheme(android.R.style.Theme_Black);
    }
}

Alternate Resources (for alternate languages and configurations)

You can supply different resources for your application to use depending on the UI language or hardware configuration on the device. Note that although you can include different string, layout, and other resources, the SDK does not expose methods to let you specify which alternate resource set to load. Android detects the proper set for the hardware and location, and loads them as appropriate. Users can select alternate language settings using the settings panel on the device.

여러분은 디바이스 상의 UI 언어 또는 하드웨어 설정에 의존해서, 여러분의 애플리케이션이 사용할 서로 다른 리소스를 제공할 수 있다. 여러분이 다른 문자열들, 레이아웃들 그리고 그 밖의 리소스들을 포함할 수 있을지라도, SDK는 어떤 택일적alternate 리소스가 로드되어야 하는가를 지정하는 메쏘드를 여러분에게 제시하지 않는다는 것에 주의하라. 안드로이드는 그 하드웨어와 위치location에 알맞은 집합을 찾아내어 적절하게 그것을 로드한다. 사용자는 디바이스의 설정setting 패널을 사용하여 택일적alternate 언어 설정을 선택할 수 있다.

To include alternate resources, create parallel resource folders with qualifiers appended to the folder names, indicating the configuration it applies to (language, screen orientation, and so on). For example, here is a project that holds one string resource file for English, and another for French:

택일적alternate 리소스를 포함하기 위해서는, 폴더 이름에 그것에 적용되는 설정들(언어, 스크린 오리엔테이션 등)을 가리키는 수식어qualifiers가 덧붙여지도록 병렬적 리소스 폴더를 생성하라. 예를 들어 여기에 영어를 위한 한 개의 문자열string 리소스 파일과 프랑스어를 위한 또 다른 한 개의 문자열 리소스 파일을 가지는 프로젝트가 있다.

MyApp/
    res/
        values-en/
            strings.xml
        values-fr/
            strings.xml

Android supports several types of qualifiers, with various values for each. Append these to the end of the resource folder name, separated by dashes. You can add multiple qualifiers to each folder name, but they must appear in the order they are listed here. For example, a folder containing drawable resources for a fully specified configuration would look like this:

안드로이드는 각각에 대해 다양한 값을 가지는 여러 타입의 수식어qualifiers를 지원한다. 리소스 폴더 이름의 끝에, 이것들을 대쉬(-)로 구분되어 지게 덧붙여라. 여러분은 각각의 폴더 이름에 다양한 수식어qualifiers를 추가할 수 있으나, 여기에 나열된 순서대로 나타내야 한다. 예를 들어 모든 설정을 명시하는 드로어블drawable 리소스를 포함하는 폴더는 이렇게 보일 것이다.

MyApp/
    res/
        drawable-en-rUS-large-long-port-mdpi-finger-keysexposed-qwerty-navexposed-dpad-480x320/

More typically, you will only specify a few specific configuration options. You may drop any of the values from the complete list, as long as the remaining values are still in the same order:

보다 일반적으로, 여러분은 몇몇 특정 설정 옵션만을 지정할 것이다. 여러분은 전체 리스트에서 임의의 값들을 누락시킬 수 있다. 단, 사용된remaining 값들이 여전히 동일한 순서를 있을 때에만 가능하다.

MyApp/
    res/
        drawable-en-rUS-finger/
        drawable-port/
        drawable-port-mdpi/
        drawable-qwerty/

Table 2 lists the valid folder-name qualifiers, in order of precedence. Qualifiers that are listed higher in the table take precedence over those listed lower, as described in How Android finds the best matching directory.

테이블 2는 유효한 폴더 이름 수식어qualifier를 서열 순서로 나열한다. 안드로이드가 가장 일치하는 디렉토리를 찾는 방법에서 설명되듯이, 테이블에서 더 위쪽에 리스트된 수식어는 더 아래쪽에 리스트된 것보다 앞쪽에 놓인다.

Table 2

Qualifier Values
MCC and MNC

The mobile country code optionally followed by mobile network code from the SIM in the device. For example mcc310 (U.S. on any carrier); mcc310-mnc004 (U.S., Verizon brand); mcc208-mnc00 (France, Orange brand); mcc234-mnc00 (U.K., BT brand).

If the device uses a radio connection (GSM phone), the MCC will come from the SIM, and the MNC will come from the network to which the device is attached. You might sometimes use the MCC alone, for example to include country-specific legal resources in your application. If your application specifies resources for a MCC/MNC combination, those resources can only be used if both the MCC and the MNC match.

Language and region

The two letter ISO 639-1 language code optionally followed by a two letter ISO 3166-1-alpha-2 region code (preceded by lowercase "r"). For example fr, en-rUS, fr-rFR, es-rES.

The codes are not case-sensitive; the r prefix is used to distinguish the region portion. You cannot specify a region alone, but you can specify a language alone, for example en, fr, es.

Screen dimensions

small, normal, large

Specify that the resource is for a particular class of screen. The meanings of these are:

  • Normal screens are based on the traditional Android HVGA medium density screen. A screen is considered to be normal if it is at least this size (independent of density) and not large. Examples of such screens a WQVGA low density, HVGA medium density, WVGA high density.
  • Small screens are based on the space available on a QVGA low density screen. Considering a portrait HVGA display, this has the same available width but less height -- it is 3:4 vs. HVGA's 2:3 aspect ratio. Examples are QVGA low density and VGA high density.
  • Large screens are based on the space available on a VGA medium density screen. Such a screen has significantly more available space in both width and height than an HVGA display. Examples are VGA and WVGA medium density screens.
Wider/taller screens

long, notlong

Specify that the resource is for a taller/wider than traditional screen. This is based purely on the aspect ration of the screen: QVGA, HVGA, and VGA are notlong; WQVGA, WVGA, FWVGA are long. Note that long may mean either wide or tall, depending on the current orientation.

Screen orientation

port, land, square

Specifies that the resource is for a screen that is tall (port) or wide (land); square is not currently used.

Screen pixel density

ldpi, mdpi, hdpi, nodpi

Specifies the screen density the resource is defined for. The medium density of traditional HVGA screens (mdpi) is defined to be approximately 160dpi; low density (ldpi) is 120, and high density (hdpi) is 240. There is thus a 4:3 scaling factor between each density, so a 9x9 bitmap in ldpi would be 12x12 is mdpi and 16x16 in hdpi. The special nodpi density can be used with bitmap resources to prevent them from being scaled at load time to match the device density.

When Android selects which resource files to use, it handles screen density differently than the other qualifiers. In step 1 of How Android finds the best matching directory (below), screen density is always considered to be a match. In step 4, if the qualifier being considered is screen density, Android will select the best final match at that point, without any need to move on to step 5.

You can also specify explicit densities like 92dpi or 108dpi, but these are not fully supported by the system so should not be used.

Touchscreen type notouch, stylus, finger
Whether the keyboard is available to the user

keysexposed, keyshidden, keyssoft

If your application has specific resources that should only be used with a soft keyboard, use the keyssoft value. If no keyssoft resources are available (only keysexposed and keyshidden) and the device shows a soft keyboard, the system will use keysexposed resources.

Primary text input method nokeys, qwerty, 12key
Whether the navigation keys are available to the user

navexposed, navhidden

If the hardware's navigation keys are currently available to the user, the navexposed resources will be used; if they are not available (such as behind a closed lid), navhidden will be used.

Primary non-touchscreen
navigation method
nonav, dpad, trackball, wheel
Screen dimensions 320x240, 640x480, etc. The larger dimension must be specified first. This configuration is deprecated and should not be used; use instead screen dimension, wider/taller screens, and screen orientation described above.
SDK version The SDK version supported by the device, for example v3. The Android 1.0 SDK is v1, the 1.1 SDK is v2, and the 1.5 SDK is v3.
(Minor version) (You cannot currently specify minor version. It is always set to 0.)

This list does not include device-specific parameters such as carrier, branding, device/hardware, or manufacturer. Everything that an application needs to know about the device that it is running on is encoded via the resource qualifiers in the table above.

이 리스트는 통신사, 브랜딩, 디바이스/하드웨어, 또는 제조사 같은 디바이스 제한적 파라미터를 포함하지 않는다. 애플리케이션이 자신이 실행되는 디바이스에 대해 알아야 할 필요가 있는 모든 것은, 위의 테이블에 있는 리소스 수식어qualifiers를 통해 인코드encode된다.

All resource directories, qualified and unqualified, live under the res/ folder. Here are some guidelines on qualified resource directory names:

수식어가 붙거나 붙지 않은 모든 리소스 디렉토리는 res/ 폴더 아래에 있다. 여기에 수식어가 붙은 리소스 디렉토리 이름에 대한 약간의 가이드라인이 있다.

  • You can specify multiple qualifiers, separated by dashes. For example, drawable-en-rUS-land will apply to US-English devices in landscape orientation.
  • The qualifiers must be in the order listed in Table 2 above. For example:
    • Correct: values-mcc460-nokeys/
    • Incorrect: values-nokeys-mcc460/
  • Values are case-insensitive. The resource compiler converts folder names to lower case before processing to avoid problems in case-insensitive file systems. On case-sensitive file systems, you should keep all names lower-case or at least use a consistent case to protect your future sanity when trying to find a resource file.
  • Only one value for each qualifier type is supported. For example, if you want to use exactly the same drawable files for Spain and France, you will need two resource directories, such as drawable-rES/ and drawable-rFR/, containing identical files. You cannot have a directory named drawable-rES-rFR/.
  • Qualified directories cannot be nested. For example, you cannot have res/drawable/drawable-en.
  • 여러분은 대쉬(-)에 의해 분리되는 여러 개의 수식어를 지정할 수 있다. 예를 들어 drawable-en-rUS-land는 가로방향 오리엔테이션의 미국(US)-영어(English) 디바이스에 적용될 것이다.
  • 수식어는 위의 테이블 2에서 나열된 순서로 되어야 한다. 예를 들어 다음과 같다.
    • 옳음 : values-mcc460-nokeys/
    • 틀림 : values-nokeys-mcc460/
  • 값들은 대소문자를 구분하지 않는다. 리소스 컴파일러는 대소문자를 구분하는 파일 시스템에서의 문제를 피하기 위해서 포로세싱 전에에 폴더 이름을 소문자로 변환한다. 대소문자를 구분하는 파일 시스템에서 여러분은 모든 이름을 소문자로 유지하거나, 나중에 리소스 파일을 찾고자 할 때 여러분이 합리적으로 할 수 있도록 적어도 일관된 방식을 사용해야 한다.
  • 각각의 수식어 타입에 대해서는 오직 하나의 값만이 지원된다. 예를 들어 만약 여러분이 스페인과 프랑스을 위해 정확하게 동일한 드로어블drawable 파일을 사용하고자 한다면, 여러분은 똑같은 파일을 포함하고 있는 drawable-rES/ 와 drawable-rFR/ 과 같이 두 개의 리소스 디렉토리를 필요로 할 것이다. 여러분은 drawable-rES-rFR/ 로 명명된 디렉토리를 가질 수 없다.
  • 수식어 디렉토리는 다른 수식어 디렉토리 안에 있을 수 없다cannot be nested. 예를 들어 여러분은 res/drawable/drawable-en 을 가질 수 없다.

How resources are referenced in code

All resources will be referenced in code or resource reference syntax by their simple, undecorated names. So if a resource were named this:
MyApp/res/drawable-port-mdpi/myimage.png
It would be referenced as this:
R.drawable.myimage (code)
@drawable/myimage (XML)

모든 리소스는 코드 또는 리소스 레퍼런스 구문에서 간단하고, 꾸밈없는undecorated 이름으로 레퍼런스될 것이다. 그러므로 만약 리소스가 다음과 같이 명명되었다면,MyApp/res/drawable-port-mdpi/myimage.png그것은 아래와 같이 레퍼런스될 것이다.R.drawable.myimage (code)@drawable/myimage (XML)

If several drawable directories are available, Android will select one of them (as described below) and load myimage.png from it.

만약 여러 개의 드로어블drawable 디렉토리가 있다면 (위에서 언급되었듯이) 안드로이드는 그것 중 하나를 선택할 것이고, 그것에서 myimage.png를 로드할 것이다.

How Android finds the best matching directory

Android will pick which of the various underlying resource files should be used at runtime, depending on the current configuration of the device. The example used here assumes the following device configuration:

안드로이드는 디바이스의 현재 설정에 의존해서 런타임에서 사용되어야 하는 리소스를 아래에 놓인 다양한 리소스 파일 중에서 골라낼 것이다. 여기에서 사용되는 예제는 다음과 같은 디바이스 설정을 가정한다.

Locale = en-GB
Screen orientation = port
Screen pixel density = mdpi
Touchscreen type = notouch
Primary text input method = 12key

Here is how Android makes the selection:

여기에 안드로이드가 선택하는 방법이 있다.

  1. Eliminate resource files that contradict the device configuration. For example, assume that the following resource directories are available for drawables. The drawable-fr-rCA/ directory will be eliminated, because it contradicts the locale of the device.
    MyApp/res/drawable/
    MyApp/res/drawable-en/
    MyApp/res/drawable-fr-rCA/
    MyApp/res/drawable-en-port/
    MyApp/res/drawable-en-notouch-12key/
    MyApp/res/drawable-port-ldpi/
    MyApp/res/drawable-port-notouch-12key
    Exception: Screen pixel density is the one qualifier that is not used to eliminate files. Even though the screen density of the device is medium dpi, drawable-port-ldpi/ is not eliminated from the list, because every screen density is considered to be a match at this point.
  2. From Table 2, pick the highest-precedence qualifier that remains in the list. (Start with MCC, then move down through the list.)
  3. Do any of the available resource directories include this qualifier?
    • If No, return to step 2 and look at the next qualifier listed in Table 2. In our example, the answer is "no" until we reach Language.
    • If Yes, move on to step 4.
  4. Eliminate resource directories that do not include this qualifier. In our example, we eliminate all the directories that do not include a language qualifier.
  5. MyApp/res/drawable/
    MyApp/res/drawable-en/
    MyApp/res/drawable-en-port/
    MyApp/res/drawable-en-notouch-12key/
    MyApp/res/drawable-port-ldpi/
    MyApp/res/drawable-port-notouch-12key
    Exception: If the qualifier in question is screen pixel density, Android will select the option that most closely matches the device, and the selection process will be complete. In general, Android will prefer scaling down a larger original image to scaling up a smaller original image.

  6. Go back and repeat steps 2, 3, and 4 until only one choice remains. In the example, screen orientation is the next qualifier in the table for which we have any matches. Eliminate resources that do not specify a screen orientation.
    MyApp/res/drawable-en/
    MyApp/res/drawable-en-port/
    MyApp/res/drawable-en-notouch-12key/
    Only one choice remains, so that's it. When drawables are called for in this example application, the Android system will load resources from the MyApp/res/drawable-en-port/ directory. In addition, if the resource being loaded is a bitmap, it will be scaled up so that its supplied low density matches the device's medium density.
  1. 현재 디바이스 설정에 일치하지 않는 임의의 리소스를 제거한다. 예를 들어 드로어블drawable에 대한 다음과 같은 리소스 디렉토리가 있다고 가정하자. drawable-fr-rCA/ 디렉토리는 제거될 것이다. 왜냐하면 그것은 디바이스의 로케일locale과 일치하지 않기 때문이다.
    MyApp/res/drawable/
    MyApp/res/drawable-en/
    MyApp/res/drawable-fr-rCA/
    MyApp/res/drawable-en-port/
    MyApp/res/drawable-en-notouch-12key/
    MyApp/res/drawable-port-ldpi/
    MyApp/res/drawable-port-notouch-12key
    Exception: 스크린 픽셀 밀도는 파일을 제거하기 위해 사용되지 않는 유일한 수식어이다. 디바이스의 스크린 픽셀 밀도가 중간medium dpi임에도 불구하고, drawable-port-ldpi/ 는 그 리스트에서 제거되지 않는다. 왜냐하면 모든 스크린 밀도가 이 시점에서 일치하는 것으로 간주되기 때문이다.
  2. 테이블 2로부터, 그 리스트에 있는 가장 높은 순위의 수식어를 골라낸다(MCC로 시작해서, 그 리스트의 아래로 이동한다).
  3. 사용가능한 리소스 디렉토리 중 어떤 것이 이 수식어를 포함하는가?
    • 만약 “아니오”라면, 단계 2로 돌아가서 테이블 2에 열거된 다음 수식어를 찾는다. 우리들의 예제에서 우리가 언어에 도달할 때까지 그 답은 “아니오”이다.
    • 만약 “예”라면, 단계 4로 이동한다.
  4. 이 수식어를 포함하지 않는 리소스 디렉토리를 제거한다. 우리들의 예제에서, 우리는 언어 수식어를 포함하지 않는 모든 디렉토리를 제거한다.
    MyApp/res/drawable/
    MyApp/res/drawable-en/
    MyApp/res/drawable-en-port/
    MyApp/res/drawable-en-notouch-12key/
    MyApp/res/drawable-port-ldpi/
    MyApp/res/drawable-port-notouch-12key
    Exception: 만약 문제되는 수식어가 스크린 픽셀 밀도라면, 안드로이드는 디바이스에 가장 근접하게 일치하는 옵션을 선택할 것이다. 그리고 그 선택 절차는 완료될 것이다. 일반적으로, 안드로이드는 더 작은 원본 이미지를 키우는 것보다 더 큰 원본 이미지를 줄이는 것을 선호한다.
  5. 뒤로 돌아가서, 오직 하나의 선택이 남을 때까지 단계 2,3, 그리고 4를 반복한다. 예제에서는 스크린 오리엔테이션이 테이블에서 우리가 일치하는 다음 수식어이다. 스크린 오리엔테이션을 지정하지 않은 리소스를 제거한다.
    MyApp/res/drawable-en/
    MyApp/res/drawable-en-port/
    MyApp/res/drawable-en-notouch-12key/
    오직 하나의 선택이 남는다. 그래서 그것으로 끝난다. 이 예제 애플리케이션에서 드로어블drawable이 호출될 때, 안드로이드 시스템은 MyApp/res/drawable-en-port/ 디렉토리로부터 리소스를 로드할 것이다. 또한, 만약에 로드load된 리소스가 비트맵이라면, 제공되었던 저밀도low density 비트맵이 디바이스의 중간 밀도medium density에 맞도록 크기가 커진다.

Tip: The precedence of the qualifiers is more important than the number of qualifiers that exactly match the device. For example, in step 4 above, the last choice on the list includes three qualifiers that exactly match the device (orientation, touchscreen type, and input method), while drawable-en has only one parameter that matches (language). However, language has a higher precedence, so drawable-port-notouch-12key is out.

Tip: 디바이스와 정확하게 일치하는 수식어의 갯수보다 수식어의 순서가 더 중요하다. 예를 들어 위의 단계 4에서, drawable-en은 오직 한 개의 파라미터만 일치하는 (언어) 반면, 그 리스트에서 마지막 선택은 디바이스와 정확하게 일치하는 세 개의 수식어(오리엔테이션, 터치 스크린, 그리고 입력 방법)를 포함한다. 하지만 언어가 더 높은 서열을 가지며, 그러므로 drawable-port-notouch-12key는 제거된다.

This flowchart summarizes how Android selects resource directories to load.

다음에 나오는 순서도는 안드로이드가 로드할 리소스 디렉토리를 선택하는 방법을 정리한다.

resource-selection

Terminology

The resource system brings a number of different pieces together to form the final complete resource functionality. To help understand the overall system, here are some brief definitions of the core concepts and components you will encounter in using it:

리소스 시스템은 최종적인 완전한 리소스 기능을 만들기 위해 다수의 다른 조각들을 함께 가져온다. 전체 시스템 이해를 돕기 위해, 여기에 여러분이 그것을 사용하면서 접하게 될 핵심 개념과 컴포넌트에 대한 약간의 간단한 정의가 있다.

Asset: A single blob of data associated with an application. This includes object files compiled from the Java source code, graphics (such as PNG images), XML files, etc. These files are organized in a directory hierarchy that, during final packaging of the application, is bundled together into a single ZIP file.

Asset(애셋): 애플리케이션과 연관된 하나의 데이터 블러브blob. 이것은 java 소스 코드, (PNG 이미지와 같은) 그래픽, XML 파일 등으로부터 컴파일된 오브젝트 파일들을 포함한다. 하나의 디렉토리 계층구조로 구성된 이 파일들은, 애플리케이션의 최종 패키징 과정에서 하나의 ZIP 파일로 함께 묶여진다.

aapt: Android Asset Packaging Tool. The tool that generates the final ZIP file of application assets. In addition to collecting raw assets together, it also parses resource definitions into binary asset data.

aapt: 안드로이드 에셋 패키징 도구(Android Asset Packaging Tool). 애플리케이션 에셋의 최종 ZIP 파일을 생성하는 도구. 그것은 원시raw 에셋을 함께 모으는 것에 추가해서, 리소스 정의를 바이너리 에셋 데이터로 또한 분석한다parse.

Resource Table: A special asset that aapt generates for you, describing all of the resources contained in an application/package. This file is accessed for you by the Resources class; it is not touched directly by applications.

리소스 테이블: 여러분을 위해 aapt가 생성하는 특별한 에셋으로, application/package 안에 포함된 모든 리소스를 설명한다. 여러분은 이 파일을 리소스 클래스를 통해 접근할 수 있다. 그것은 애플리케이션에 의해 직접적으로 터치되지 않는다.

Resource: An entry in the Resource Table describing a single named value. Broadly, there are two types of resources: primitives and bags.

리소스: 하나의 지칭된 값을 설명하는 리소스 테이블 내의 엔트리entry. 대체로 그들은 두 가지 타입의 리소스가 있다: 프리미티브primitives와 백bags이 그것이다.

Resource Identifier: In the Resource Table all resources are identified by a unique integer number. In source code (resource descriptions, XML files, Java source code) you can use symbolic names that stand as constants for the actual resource identifier integer.

리소스 식별자(Identifier): 리소스 테이블에 있는 모든 리소스는 고유한 정수integer number에 의해 식별된다. 소스 코드(리소스 설명들, XML 파일들, Java 소스 코드)에서 여러분은 실제 리소스 식별자 정수integer에 대한 상수constant인 심볼릭 이름을 사용할 수 있다.

Primitive Resource: All primitive resources can be written as a simple string, using formatting to describe a variety of primitive types included in the resource system: integers, colors, strings, references to other resources, etc. Complex resources, such as bitmaps and XML describes, are stored as a primitive string resource whose value is the path of the underlying Asset holding its actual data.

프리미티브(Primitive) 리소스: 모든 프리미티브 리소스는 리소스 시스템에 포함된 다양한 프리미티브 타입(정수(integer), 컬러(color), 문자열(string), 다른 리소스에 대한 레퍼런스 등)을 기술하는 포맷팅을 사용해서 간단한 문자열로 작성될 수 있다. 비트맵과 XML 표현과 같은 복잡한 리소스은 프리미티브 문자열 리소스로 저장되며, 그 문자열 리소스의 값은 그것의 실제 데이터를 보유하는 에셋의 경로이다.

Bag Resource: A special kind of resource entry that, instead of a simple string, holds an arbitrary list of name/value pairs. Each name is itself a resource identifier, and each value can hold the same kinds of string formatted data as a normal resource. Bags also support inheritance: a bag can inherit the values from another bag, selectively replacing or extending them to generate its own contents.

백(Bag) 리소스: 간단한 문자열 대신, 임의의 이름/값 쌍name/value pairs 리스트를 보유하는 특별한 종류의 리소스 엔트리. 각각의 이름은 그 자체로 리소스 식별자이며, 그리고 각각의 값은 보통의 리소스와 같은 종류의 문자열로 포맷된 데이터를 보유할 수 있다. 백Bags은 또한 상속을 지원한다. 백bag은 다른 백bag으로부터 값들을 상속할 수 있으며, 그것 자신의 컨텐츠들을 생성하기 위해 그것들을 선택적으로 대체하거나 또는 확장할 수 있다.

Kind: The resource kind is a way to organize resource identifiers for various purposes. For example, drawable resources are used to instantiate Drawable objects, so their data is a primitive resource containing either a color constant or string path to a bitmap or XML asset. Other common resource kinds are string (localized string primitives), color (color primitives), layout (a string path to an XML asset describing a view layout), and style (a bag resource describing user interface attributes). There is also a standard "attr" resource kind, which defines the resource identifiers to be used for naming bag items and XML attributes

종류(kind): 리소스 종류는 다양한 목적을 위해 리소스 식별자를 구성하는 방법이다. 예를 들어 드로어블drawable 리소스는 드로어블Drawable 오브젝트를 인스턴스화하기 위해 이용된다. 그래서 그들의 데이터는 비트맵 또는 XML 에셋에 대한 컬러 상수나 문자열 경로를 포함하는 프리미티브 리소스이다. 그 밖의 보편적인 리소스 종류에는 문자열(로컬라이즈된 문자열 프리미티브), 컬러(컬러 프리미티브), 레이아웃(뷰 레이아웃을 기술하는 XML 에셋에 대한 문자열 경로), 그리고 스타일(사용자 인터페이스 애트리뷰트를 기술하는 백(bag) 리소스)이 있다. 또한 표준 “attr” 리소스 종류가 있다. 이것은 백bag 아이템과 XML 애트리뷰트를 네이밍naming하기 위해 사용되는 리소스 식별자를 정의한다.

Style: The name of the resource kind containing bags that are used to supply a set of user interface attributes. For example, a TextView class may be given a style resource that defines its text size, color, and alignment. In a layout XML file, you associate a style with a bag using the "style" attribute, whose value is the name of the style resource.

스타일: 사용자 인터페이스 애트리뷰트에 대한 하나의 집합을 제공하기 위해 사용되는 백bag을 포함하는 리소스 종류의 이름. 예를 들어 TextView 클래스에는 텍스트 크기, 컬러, 그리고 정렬을 정의하는 스타일 리소스가 주워질 수도 있다. 여러분은 레이아웃 XML 파일에 “style” 애트리뷰트를 사용하는 백bag을 가지고 하나의 스타일을 결합시킬 수 있다. 그 style의 값은 스타일 리소스의 이름이다.

Style Class: Specifies a related set of attribute resources. This data is not placed in the resource table itself, but used to generate constants in the source code that make it easier for you to retrieve values out of a style resource and/or XML tag's attributes. For example, the Android platform defines a "View" style class that contains all of the standard view attributes: padding, visibility, background, etc.; when View is inflated it uses this style class to retrieve those values from the XML file (at which point style and theme information is applied as approriate) and load them into its instance.

스타일 클래스: 관련된 애트리뷰트 리소스의 집합을 명시한다. 이 데이터는 리소스 테이블 자체에 위치하지 않는다. 하지만 소스 코드에서 상수를 생성하기 위해 사용되며, 그것은 여러분으로 하여금 스타일 리소스 및/또는 XML 태그의 애트리뷰트로부터 값을 얻어오는 것을 더 용이하게 한다. 예를 들어 안드로이드 플랫폼은 모든 표준 뷰 애트리뷰트들(패딩(padding), visibility(비저블리티), background(백그라운드) 등)을 포함하는 “View” 스타일 클래스를 정의한다. 뷰가 인플레이트inflate될 때, 뷰는 XML 파일로부터 스타일 리소스 관련 값을 가져오기 위해 이 스타일 클래스를 사용하며(이 시점에 스타일과 테마 정보가 적절하게 적용된다), 스타일 리소스 값들을 뷰의 인스턴스 안으로 로드한다.

Configuration: For any particular resource identifier, there may be multiple different available values depending on the current configuration. The configuration includes the locale (language and country), screen orientation, etc. The current configuration is used to select which resource values are in effect when the resource table is loaded.

설정(Configuration): 어떤 특별한 리소스 식별자에 대해, 현재의 설정에 의존하는 복수의 다른 유효한 값들이 있을 수 있다. 설정은 로케일(언어와 국가), 스크린 오리엔테이션, 스크린 밀도 등을 포함한다. 현재 설정은 리소스 테이블이 로드될 때 어떤 리소스 값을 실제로 선택하기 위해 사용된다.

Theme: A standard style resource that supplies global attribute values for a particular context. For example, when writing an Activity the application developer can select a standard theme to use, such as the Theme.White or Theme.Black styles; this style supplies information such as the screen background image/color, default text color, button style, text editor style, text size, etc. When inflating a layout resource, most values for widgets (the text color, selector, background) if not explicitly set will come from the current theme; style and attribute values supplied in the layout can also assign their value from explicitly named values in the theme attributes if desired.

테마(Theme): 특별한 컨텍스트에 대한 글로벌 애트리뷰트 값을 제공하는 표준 스타일 리소스. 예를 들어 액티비티를 만들 때, 애플리케이션 개발자는 Theme.White 또는 Theme.Black 스타일과 같은 사용할 표준 테마를 선택할 수 있다. 이 스타일은 스크린 백그라운드 이미지/컬러, 디폴트 텍스트 컬러, 버튼 스타일, 텍스트 에디터 스타일, 텍스트 크기 등과 같은 정보를 제공한다. 레이아웃 리소스를 인플레이트inflate할 때, 만약 위젯에 대한 대부분의 값(텍스트 컬러, 실렉터(selector), 백그라운드)이 명시적으로 설정되지 않는다면 현재 테마로부터 가져올 것이다. 레이아웃에 제공된 스타일과 애트리뷰트 값 또한 필요하다면 테마 애트리뷰트에서 명시적으로 명명된 값으로 그것들의 값을 지정할 수 있다.

Overlay: A resource table that does not define a new set of resources, but instead replaces the values of resources that are in another resource table. Like a configuration, this is applied at load time to the resource data; it can add new configuration values (for example strings in a new locale), replace existing values (for example change the standard white background image to a "Hello Kitty" background image), and modify resource bags (for example change the font size of the Theme.White style to have an 18 pt font size). This is the facility that allows the user to select between different global appearances of their device, or download files with new appearances.

오버레이(Overlay): 리소스의 새로운 집합을 정의하지 않는 리소스 테이블은, 대신에 다른 리소스 테이블에 있는 리소스 값을 대체한다. 설정과 같이 이것은 로드 시점에 리소스 데이터에 적용된다. 그것은 새로운 설정 값(예를 들어 새로운 로케일 안의 문자열)을 추가할 수 있고, 기존에 있는 값(예를 들어 “Hello Kitty” 백그라운드 이미지로 표준 화이트 백그라운드를 변경)을 대체하고, 리소스 백bag(예를 들어 18 pt 폰트 크기로 Theme.White 스타일의 폰트 사이즈를 변경)을 수정할 수 있다. 이것은 사용자로 하여금 그들의 디바이스의 전체적인 외관appearance을 선택하는 것을 가능하게 하며, 새로운 외관을 사용하는 파일을 다운로드하는 것을 가능하게 하는 설비이다.

Resource Reference

The Available Resources document provides a detailed list of the various types of resource and how to use them from within the Java source code, or from other references.

“사용가능한 리소스” 문서는 리소스의 다양한 타입에 대한 상세한 리스트와 Java 소스 코드, 또는 다른 레퍼런스에서 그것들을 사용하는 방법을 제공한다.

Internationalization and Localization

Coming Soon: Internationalization and Localization are critical, but are also not quite ready yet in the current SDK. As the SDK matures, this section will contain information on the Internationalization and Localization features of the Android platform. In the meantime, it is a good idea to start by externalizing all strings, and practicing good structure in creating and using resources.

Coming Soon: 국제화Internationalization와 지역화Localization는 중요하다. 하지만 또한 현재 SDK에서는 아직 완전히 준비되어 있지 않다. SDK가 성숙해지면서, 이 섹션은 안드로이드 플랫폼의 국제화와 지역화 특징들에 대한 정보를 포함할 것이다. 그 동안에는, 모든 문자열을 외부화시켜서, 리소스를 생성하고 사용하기 좋은 구조를 유지하고 있는 것이 좋다. (역주 : 최근 지역화와 관련된 구글 문서가 추가되고 있음, http://developer.android.com/guide/topics/resources/localization.html)

↑ Go to top

← Back to Resources and Assets