This article in fact long wanted to tidy up, the main reason is that I do not pay attention to the application of resources, very little attention to this thing, but this thing is not difficult, but it is very important (especially when the need to change).
If you differentiate from source code, it can be divided into three main categories:
1. Interface layout file, XML file, each label in the file corresponds to the relative view tag.
2.Java source files.
3. Resource files: mainly in a variety of XML-based, but also can include some pictures, audio and video resources.
If you want to divide by resource type, it can be divided into the following two major categories:
1. The OST resources that can be accessed through the R manifest class are saved in the assets directory. Need to be taken by Getassets ().
2. Resources that can be accessed through R are saved in the Res directory.
There can be a lot of storage in the res, as and Eclipse directories are a little different, but I feel the whole is the case, because my computer eclipse ran up, so I used eclipse introduced.
These resources can be obtained through getresource
Use string, color, and size resource resources:
Colors
<resources> <color name= "TITLE_BG" > #ff0cbaa0 </color></resources>
Dimens:
<resources> <dimen name= "Activity_horizontal_margin" >16dp</dimen> <dimen name= " Activity_vertical_margin ">16dp</dimen></resources>
Strings
<resources> <string name= "App_name" >Lottery</string></resources>
If you use it, you can use it in XML.
can also be used to define the bool type ... <bool name= "GG" >true</bool>
Array resources:
<array name= "" ><item></item></array>
<string-array. />
<integer-array. />
Statelistdrawable Resources:
Used to organize multiple drawable objects, in fact, we usually say selector.
Shapedrawable: Used to define a basic geometry
<shape android:shape= "[rectangle,oval,line,ring]" >
<corners/> radians
<gradient/> Defining gradient Fills
<padding/> defining the padding for a geometry shape
<size/> size
<solid/> fill with a single color
<stroke/> define a border to draw for a geometry shape
</shape>
You can also define some raw XML files to parse by pull.
Internationalization:
Basename_language_country.properties
For example language VALUE-ZH-RCN add Chinese, Values-en-rus will add English. He will be based on the text of the phone set himself to find the corresponding text.
Adaptive different screens:
To consider screen size (small, medium, large, super Large), screen resolution (Low, Medium, High, superelevation), screen orientation
Some will use values-how many times to take some different size. But sometimes it's just the weight of the screen (which makes it easier).
About the resources, internationalization and resource adaptation of Android apps