Umesh

Untitled Document

Thursday, 21 March 2013

Design your own check box in android


Hello guys, if you want to design your own check box for your android app then just go through fallowing steps : 


 Step 1 : Add these four images in your drawable folder 


checkbox_on_background_focus_yellow.png

checkbox_off_background.png

checkbox_on_background.png

checkbox_off_background_focus_yellow.png



Step 2 : Also add following chk.xml in your drawable folder 


chk.xml : 


<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/checkbox_on_background_focus_yellow" android:state_checked="true" android:state_focused="true"/>
    <item android:drawable="@drawable/checkbox_off_background_focus_yellow" android:state_checked="false" android:state_focused="true"/>
    <item android:drawable="@drawable/checkbox_off_background" android:state_checked="false"/>
    <item android:drawable="@drawable/checkbox_on_background" android:state_checked="true"/>

</selector>


Step 3 : write following code in check box property in your main layout 


android:background="@drawable/chk"


No comments:

Post a Comment