Most of the time, we don't use the checkbox style of the android comes with our UI, so we need to customize our checkbox.
First look for two checkbox background images, like:
Then, in the Drawable directory, define a background image XML file with the following content:
<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android "> <item android:state_checked=" true "android:drawable=" @drawable/fuxuan_input01 "/> < Item android:state_selected= "True" android:drawable= "@drawable/fuxuan_input01" ></item> <item Android:state_pressed= "true" android:drawable= "@drawable/fuxuan_input01" ></item> <item android: State_checked= "false" android:drawable= "@drawable/fuxuan_input02"/></selector>
Define it where you want to use the checkbox, as shown in the following code:
<checkbox android:id= "@+id/agree_provision_chk" android:layout_width= "Wrap_content" android: layout_height= "Wrap_content" android:background= "@drawable/chk_agee_provision_background" android: button= "@null"/>
This completes the custom checkbox, as shown in the following:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Custom checkbox Style