0

How do I change the checkbox to have a white border? I added the checkbox to a dark colored background and as you can see, it's barely visible.

enter image description here

Mike Laren
  • 8,028
  • 17
  • 51
  • 70
Alan
  • 9,331
  • 14
  • 52
  • 97

1 Answers1

3

you need to create a 2 different drawable for checked state & non checked state. example-

checkbox_selector.xml

<?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/white_color_box_with_tick" />
    <item android:state_checked="false" android:drawable="@drawable/white_color_box_without_tick" />
</selector>

And set this drawable in the following way-

<CheckBox
    android:text="Custom CheckBox"
    android:button="@drawable/checkbox_selector"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/> 
Amit K. Saha
  • 5,871
  • 2
  • 27
  • 35