2

I am using custom AppCompatCheckBox, but i need to change the thickness and color border of the checkbox, which should look like this :

enter image description here

Parth Anjaria
  • 3,961
  • 3
  • 30
  • 62

2 Answers2

2

Please make a drawable using this code which shows the checkbox :

draw_chackbox.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>    
<layer-list>  
<item>    
<shape android:shape="rectangle">
<padding android:bottom="2dp"
android:left="2dp"
android:right="2dp"
android:top="2dp"/>    
<corners android:radius="4dp"/>
<size android:height="24dp"
android:width="24dp"/>
<stroke android:color="@color/gray_default_font"
android:width="1dp"/>
</shape>    
</item>    
</layer-list>   
</item>
</selector>

and add this drawable in the check box property using

<CheckBox 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:text="new" 
    android:button="@drawable/draw_chackbox" />

add this in main layout. hope it will help you.

Hemant Parmar
  • 3,924
  • 7
  • 25
  • 49
Kartik Shah
  • 866
  • 5
  • 19
0

You just need to set the related drawables and set them in the checkbox:

<CheckBox 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:text="new checkbox" 
    android:background="@drawable/my_checkbox_background"
    android:button="@drawable/my_checkbox" />

Here's a good tutorial about this.

Fenil Patel
  • 1,528
  • 11
  • 28