Recently prepared to learn a system of Android development, here will not copy the original text, only for some difficult to understand the tutorial part of the explanation, I am just a rookie.
In the first chapter of the tutorial-the basics of getting started, the section explaining the Android theme will probably have the following code:
<!--location Res/values/themes.xml -<?XML version= "1.0" encoding= "Utf-8"?> <Resources> <!--topics for programs or activities - <stylename= "Customactionbartheme"Parent= "@style/theme.appcompat.light.darkactionbar"> <!--api_7+ - <Itemname= "Actionbarstyle">@style/myactionbar</Item> <!--api_11+ - <Itemname= "Android:actionbarstyle">@style/myactionbar</Item> </style> <stylename= "Myactionbar"Parent= "@style/widget.appcompat.light.actionbar.solid.inverse"> <!--api_7+ - <Itemname= "Background">@drawable/actionbar_background</Item> <!--api_11+ - <Itemname= "Android:background">@drawable/actionbar_background</Item> </style></Resources>
This code is used to define your own style: change the background of the Actionbar, the problem here is that the api-7 and api-11 code is written in the same file, the result can not be compiled through eclipse, The solution is to divide this themes.xml into multiple files, and the project automatically generates VALUES-V7, Values-v11, VALUES-V14, Themes.xml can be divided into several different versions of the different values, different devices of different styles is probably the way to achieve it?
The original text on the StackOverflow:
EDIT : If you want to is able to style your ActionBar
to look the same in all APIs levels, you need To create different folders for the selected API level and create new style.xml / themes.xml
files in these folders. For example:
- res -- values -- styles.xml APILEVEL 8+ -- values-v11 -- styles.xml APILEVEL11+ -- values-v14 -- styles.xml APILEVEL 14+
There is no specific description in the tutorial to add a resource: @drawable/actionbar_background, just add a 1x1 pixel image, background The default effect is to stretch.
Finish
Android Official Development Tutorials explained (i)