Chapter 12: Managing Android Resources
Android devices come in many different forms and sizes. You’ve read in several places in this book that the Android SDK provides developers with great tools for building software that scales nicely to all devices. Now it is time to take a look at those tools.
This chapter talks about the Android resource management framework. It allows developers and designers to provide multiple alternative resources for an app and let the operating system use the correct ones for each device. After the resource manager overview, this chapter dives into the individual device properties, or qualifiers, that you can use.
Using Android resources
The Android operating system allows you to add multiple alternative resources to your app. The operating system picks the correct resource during runtime based on the runtime environment. This way, you can provide correct density graphics, the right kind of layouts for larger screens, correct language translations, and even alternative attributes for non-touch devices.
There are multiple types of resources that can be used in any Android app. The Resource Manager manages them, and the same rules apply to them. They need to be placed into the correct resource folder in your app project structure under the
• Animation definitions. (
res/anim/ and res/animator/)
• Color state list definitions. (
• Drawables. These can be bitmaps or XML drawable definitions. More about these in Chapter 14. (