I am using custom AppCompatCheckBox, but i need to change the thickness and color border of the checkbox, which should look like this :
Asked
Active
Viewed 3,116 times
2
-
try https://stackoverflow.com/a/26447763/8089770 – Vidhi Dave Dec 26 '17 at 10:02
-
Do you want to keep material effect ? if not then a single selector XMl will work . – ADM Dec 26 '17 at 10:09
-
I want to keep the material effect. – Parth Anjaria Dec 26 '17 at 10:11
2 Answers
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
-
3this will cause the layout checkbox not being able to be checked. – Dimas Mendes May 12 '19 at 08:17
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" />

Fenil Patel
- 1,528
- 11
- 28