:
Unchecked state:
Check Status:
Steps to use:
1. Create your own selector
<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <item android:drawable=" @drawable/cb_pressed "android:state_checked=" true "></item> <item android:drawable= "@drawable/cb_normal" android:state_checked= "false" ></item></selector >
2. Add the style of your own check box to the style:
<style name= "MyCheckBox" parent= "@android: Style/widget.compoundbutton.checkbox" > <item name= "Android : Button "> @drawable/mycheckboxselector</item> </style>
3. Set the Style property on your checkbox:
<relativelayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools " android:layout_width=" match_parent " android:layout_height=" Match_parent " tools:context= "com.example.testcheckboxlogo.MainActivity" > <checkbox android:id= "@+id/cb_ Main " style=" @style/mycheckbox " android:layout_width=" wrap_content " android:layout_height=" Wrap_ Content " android:layout_centerhorizontal=" true " android:layout_centervertical=" true " Android: text= "own check box"/></relativelayout>
Picture resources: You can right-click on another computer
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android checkbox unchecked state is selected replace with your own picture