1. 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 in 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"/>
Used image resources
Checkbox_normal.png
Checkbox_pressed.png