Build your own theme, component your style

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.