1. First add the drawable file Checkbox_style.xml in the Drawable folder.
[HTML]View Plaincopy
- <? XML version= "1.0" encoding="Utf-8"?>
- <selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable= "@drawable/checkbox_pressed" android:state_checked="true"/ >
- <item android:drawable= "@drawable/checkbox_normal" android:state_checked="false" />
- <item android:drawable="@drawable/checkbox_normal"/>
- </selector>
2. Add the Customcheckboxtheme style to the Styles.xml file under the Values folder.
[HTML]View Plaincopy
- <style name= "Customcheckboxtheme" parent = "@android: Style/widget.compoundbutton.checkbox" >
- < item name= "Android:button" span class= "tag" >> @drawable/checkbox_style</item >
- </style>&NBSP;&NBSP;
3. Use the Customcheckboxtheme style in the layout file.
[HTML]View Plaincopy
- <CheckBox
- android:id="@+id/select_all"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- style="@style/customcheckboxtheme" />
Picture resources to use
Checkbox_normal.png
Checkbox_pressed.png