Directory Resource Types


XML files that are compiled into frame by frame animation or tweened animation objects


.png, .9.png, .jpg files that are compiled into the following Drawable resource subtypes: To get a resource of this type, use Resource.getDrawable(id)

bitmap files

9-patches (resizable bitmaps)


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


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.

• strinas.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.


Arbitrary XML files that are compiled and can be read at run time by calling Resources.getXML().


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.openRawResourceO 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

0 0

Post a comment