1. First create the checkbox_color.xml resource in the color resource file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/blue"/>
<item android:state_checked="false" android:color="@color/gray"/>
</selector>
2. Then set the buttonTint inside the Checkbox tag
buttonTint will change the color of the button
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleX="2"
android:scaleY="2" //scaleX和scaleY用来改变复选框大小
android:layout_marginEnd="40dp"
android:buttonTint="@color/checkbox_color"/>