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