Supported resource types

In source, resources are kept in the res directory and can be one of several types:

■ res/anim—XML representations of frame-by-frame animations

■ res/layout—XML representations of View objects

■ res/values—XML representations of strings, colors, styles, dimensions, and arrays

■ res/xml—User-defined XML files (that are also compiled into a binary form)

■ res/raw—Arbitrary and uncompiled files that can be added

Resources are treated specially in Android because they are typically compiled into an efficient binary type (with the noted exception of items that are already binary and the raw type, which is not compiled). Animations, layouts and views, string and color values, and arrays can all be defined in an XML format on the platform. These XML resources are then processed by the aapt tool, which we met in chapter 2, and compiled. Once resources are in compiled form they are accessible in Java through the automatically generated R class.

0 0

Post a comment