Andorid-style, build your ownTheme,components of yourStyle
Preface :
Today, try a new demo, but also try to learn more, talk about, see, this demo How to implement the custom theme and component Style How it's bound.
At the right, the Du and Dummy buttons are custom component themes. Consider how the following topic is bound to the Style of the component .
1. Custom APP theme , a general theme, equivalent to the Java factory model or a Map table , through which you can invoke other component Style, such as the following defined
Metabuttonbarstyle and Circlebuttonbarbutton
<stylename= "Fullscreentheme"Parent= "Android:Theme.Holo"> <Itemname= "Android:actionbarstyle">@style/fullscreenactionbarstyle</Item> <Itemname= "Android:windowactionbaroverlay">True</Item> <Itemname= "Android:windowbackground">@null</Item> <Itemname= "Metabuttonbarstyle">? android:attr/buttonbarstyle</Item> <Itemname= "Circlebuttonbarbutton">@style/circlebuttonbarbutton</Item></style>
2 Metabuttonbarstyle and Circlebuttonbarbutton 2. Defining Component Themes
The code is as follows :
<!--backward-compatible version of? Android:attr/buttonbarstyle -<stylename= "Buttonbar"> <Itemname= "Android:paddingleft">2dp</Item> <Itemname= "Android:paddingtop">5dp</Item> <Itemname= "Android:paddingright">2dp</Item> <Itemname= "Android:paddingbottom">0dp</Item> <Itemname= "Android:background">@android:d Rawable/bottom_bar</Item></style><!--backward-compatible version of? Android:attr/buttonbarbuttonstyle -s<stylename= "Circlebuttonbarbutton"> <Itemname= "Android:paddingleft">2dp</Item> <Itemname= "Android:paddingtop">5dp</Item> <Itemname= "Android:paddingright">2dp</Item> <Itemname= "Android:paddingbottom">8dp</Item> <Itemname= "Android:background">@drawable/circle_btn</Item></style>
3. How is the layout interface called and what components are there? What can be used? Is the generalist attrs to invoke a
<Resources> <!--Declare Custom theme attributes that allow changing which styles is used for button bars depending on the AP I level. ? Android:attr/buttonbarstyle is new as of API one-so-necessary to-support previous API levels. - <declare-styleablename= "Buttonbarcontainertheme"> <attrname= "Metabuttonbarstyle"format= "Reference" /> <attrname= "Circlebuttonbarbutton"format= "Reference" /> </declare-styleable></Resources>
4. All written well, can be used, can also consider to do a theme library or something, the 9path picture, custom component style, and so on, to form a Theme, as long as the twenty or thirty components to do well, is a complete library .
Android:id="@+id/test"style="? Metabuttonbarstyle"Android:layout_width="0DP"Android:layout_height="wrap_content"Android:layout_weight="1"Android:text="@string/dummy_button"/><Button Android:id="@+id/dummy_button"style="? Circlebuttonbarbutton"Android:layout_width="48DP"Android:layout_height="48DP"Android:text="@string/dummy_button"android:layout_gravity="Right|bottom"/>
Build your own theme, component your style