Android Resource types Tutorial
Today we shall study types of Android resources. We shall have a brief introduction and a glance over the types. It is theoretical so please be patient.
Android resource types are as follows:
- Drawable resources
- Color state list resources
- Animation resources
- Layout resources
- Menu resources
- Style resource
- String resources
5.4.2 Android Drawable Resources
These resources define the graphics of application with xml or bitmaps. They are accessed from R.drawable class and saved in res/drawable/ folder. It is a general concept for a graphic that can be drawn to the screen which can be retrieved with APIs. The different types of drawables are as follows:
- Nine-Patch file: This is a PNG file which has stretchable regions. With this image can be resized according to content.
- Layer List: This is a drawable which manages an array of other Drawables They are drawn in array order. Element with largest index will be at top.
- Level list: This is an XML file. It defines one drawable which manages number of alternate drawables. These alternatives are assigned with a maximum number.
- Bitmap file: This is a simple bitmap graphic file.
- Clip drawable: This XML file defines a drawable that clips another drawable.
- Shape drawable: This XML file defines geometric shape.
- Transition drawable: This Xml file deals with the transition. It cross-fades between two drawable resources.
5.4.3 Android Color State List Resources
A ColorStateList is an object which can be defined in XML. This can be applied as a color. Depending on the state of view object to which it is applied the color actually changes. Each color can be defined in a XML file under <item /> tag. So the state list in an XML file can be described. When state changes, state list is traversed from top to bottom and the most suitable match is picked.
5.4.4 Android Animation Resource
There are two types of animations which an animation resource can refer to and they are:
- Property Animation: An animator is used to set an object’s property over a period of time. In short we modify the properties of object.
- View Animation: There are two types of animations which can be viewed:
- Frame animation: A sequence of images is displayed in order
- Tween animation: An animation is created by performing a series of transformations on a single image.
5.4.5 Android Layout Resource
Android layout resource is used to define the user interface of application. We already know the usage of layouts so there is no point in redundancy.
5.4.6 Android Menu
Android Menu resource is used to design and define the menu of application. We have options menu, context menu and submenu. This can be inflated by MenuInflater.
5.4.7 Android String Resource
Android String resource provides text strings for application. We have an option to format text and style it as well. We have three types of resources:
- String Array: It is an xml resource which provides an array of strings
- String: This is an xml resource which provides a single string
- Quantity Strings: It is an xml resource. It carries the strings for pluralization.
5.4.8 Android Style Resources
Style resource as the name suggests it is going to define the format and look of user interface. An individual view can have a specific style. An entire activity or an application can be stylized by manifest file. It is nothing but a resource which has to be referenced properly.
Other resources are listed below:
- Color: It is an xml resource which has a hexadecimal number. This number corresponds to a particular color.
- Bool: This resource carries a color value.
- Dimension: It contains the value of dimension with the specific unit of measure.
- ID: This is also an xml resource. This is an unique identifier which identifies application resources and components.
- Integer: It is an xml resource which carries an integer value.
- Typed Array: We can use this as array of drawables.
- Integer Array: It is an xml resource and it is an array of integers.
So congratulations guys. we are done with our short tutorial over resources. Stay tuned. As I say, keep practicing. Happy App Developing!!!