-2

enter image description here

How can i make the checkbox as like the image in android. can anyone help me?

harini
  • 73
  • 1
  • 1
  • 7

1 Answers1

1

First: In you res/drawable folder, create "custom_checkbox.xml"

<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@drawable/cbox" android:state_checked="false"/>
    <item android:drawable="@drawable/cbox_selected" android:state_checked="true"/>
    <item android:drawable="@drawable/cbox"/>    
</selector>

Second: In you res/drawable-hdpi folder, paste two files named "cbox.png(which is unselected image of checkbox) and cbox_selected.png(which is selected Image of checkbox)"

Third: Now in you checkbox declaration

<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:button="@drawable/custom_checkbox" />
Murtaza Khursheed Hussain
  • 15,176
  • 7
  • 58
  • 83