Android Development Department, it is inevitable to set a certain type of button press, click, focus and other states, usually for this kind of problem, the most primitive way is set in the layout file, but for a larger project, this approach caused by the maintainability is not very good, So try to do code reuse as much as possible.
There are typically 3 settings-style resource folders in an Android project
Values
Values-11
Values-14
These three styles for the SDK versions of the different platforms, for Android development compatibility issues, to " let the latest API run in the latest Android SDK ", this is a very good behavior.
The values file is mainly used to set the theme style, permissions according to platform segmentation, that is android4.x will be the first to find values-14 to find values-11 finally find values,android2.x first find values-11 finally find values
The above is a setup problem for values, usually style.xml is used to set the window and activity themes and styles, but in fact, Style.xml can also be used to set the global style of the control.
Here is a famous saying:
Try to keep the theme style and page style consistent, colorful is the ugliest style.
--I, December 07, 2014 Final Summary
For a control, such as Togglebutton,radiobutton,checkbox, scroll bar color, Button, the style is different before and after the state switch when clicked.
In general, there are 2 kinds of settings, such as I set the font:
Style.xml-1
<style name= "Text_red_20_blod" > <item name= "android:textstyle" >bold</item> <item name= " Android:textsize ">20.0sp</item> <item name=" Android:textcolor "> @color/red_text_color</item> </style>
This limitation and in person to the layout file settings, just a lot less code, improve reusability, it can be said that only part of the global.
Style.xml-2
<style name= "Apptheme" parent= "Android:Theme.Holo.Light" > <item name= "Android:textstyle" >bold</item > <item name= "android:textsize" >20.0sp</item> <item name= "Android:textcolor" > @color/red _text_color</item></style>
This kind of thing the most overall, enhances the reusability, certainly also has his shortcoming, this inevitably, then in the development, how do we choose?
-
The most frequently changing view style in style.xml-1, which avoids excessive code accumulation in the layout file, just like CSS styles
-
Style.xml-2 is suitable for a more unified view style, that is, some view of the commonality of unity, in general, such as Togglebutton,checkbox,button, such as the view of the state switch style in the same project always maintain a constant change effect. That is, when we use the custom to put the ToggleButton switch state, the next time to use the ToggleButton style should be consistent with the last style .
-
Conflict, if the content of using STYLE.XML-1 under Style.xml-2 will be displayed, the question can be described in one sentence: "The lower the overall, the higher the control," in other words, STYLE.XML-1 control permissions are higher than Style.xml-2, so if the style of the view style that affects a control is set, then the right to use style= "@style/xxxx" is higher than the subject permission.
Try doing it
Android sets the global style and style of the view control