Themes and selectors

Source: Internet
Author: User

Today I do the bottom tab because the style is the same, so you can customize a style to save a lot of repeating style (lazy lazy), zai9values/styles.xml add RadioButton style:

    <style name= "Bottomtabstyle" >        <item name= "Android:layout_width" >wrap_content</item>        <item name= "Android:layout_height" >wrap_content</item>        <item name= "Android:layout_weight" > 1</item>        <item name= "Android:button" >@null</item>        <item name= "Android: Gravity ">center</item>        <item name=" android:padding ">5dp</item>        <item name=" Android:drawablepadding ">3dp</item>        <item name=" Android:textcolor "> @color/txt_bottom_tab_ Selector</item>    </style>

Color Picker Add Txt_bottom_tab_selector.xml in Res/color:

<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android ">    <item android:state_checked=" true "android:color=" #f00 "></item>//state_checked is selected after State_pressed is press <item android:color= "#fff" ></item>//default </selector>

Picture selector: res/drawable

<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android ">    <item android:drawable=" @drawable/home_press "android:state_checked=" true "></item>    <item android:drawable= "@drawable/Home" ></item></selector>

Use style in layout to introduce theme styles: Drawabletop @drawable introduction of Image Selector

       <RadioButton            android:id= "@+id/rb_home"            style= "@style/bottomtabstyle"             android:drawabletop= "@drawable/btn_home_selector"            android:checked= "true"             Android:text= "Home"/>

A little bit of lazy tricks

Themes and selectors

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.