Unfortunately, changing the color of checkbox check mark isn't a simple attribute
Create a selector xml file in resdrawables
folder with name cb_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/checked" />
<item android:state_checked="false" android:drawable="@drawable/unchecked" />
</selector>
In your layout file apply this file to your checkBox
<CheckBox
android:id="@+id/cb"
android:text="My CheckBox"
android:button="@drawable/cb_selector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Add a unchecked.png
, and checked.png
in your drawables
folder. These are checked and unchecked image of checkbox.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…