1. First add the drawable file Checkbox_style.xml in the Drawable folder.
<?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.
<style name="customcheckboxtheme" parent="@android: style/ Widget.CompoundButton.CheckBox"> <item name="android:button" > @drawable/checkbox_style</item> </style>
3. Use the Customcheckboxtheme style in the layout file.
<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
- < checkbox
- android:id "@+id/select_all"
- android:layout_width "wrap_content"
- android:layout_height "wrap_content"
- style="@style/customcheckboxtheme" />
Customize checkbox style in Android