3

In my XML contains one CheckBox. How to change check box border color via programmatically in android.

My Sample ScreenShot is here ScreenShot

Thanks.

Dinesh Lingam
  • 293
  • 3
  • 6
  • 13

1 Answers1

3

you can set

check.setButtonDrawable(mContext.getResources().getDrawable(
                    R.drawable.radio));

in radio.xml you can set any background to your check box.

in radio.xml

<?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
     <item android:drawable="@drawable/option_unselected" android:state_checked="false"/>
     <item android:drawable="@drawable/option_selected" android:state_checked="true"/>
 </selector>

here option_selected and option_selected are the graphics for selected and unslected state.

for more you can check http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

Taier
  • 2,109
  • 12
  • 22
Mohsin Naeem
  • 12,542
  • 3
  • 39
  • 53