Home > database >  How to change AppCompatCheckBox tick color?
How to change AppCompatCheckBox tick color?

Time:07-19

Here is my AppCompatCheckBox

     <androidx.appcompat.widget.AppCompatCheckBox
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:checked="true"
                        android:text="hello123"
                        android:theme="@style/MyCheckBox"
                        android:textColor="#ffffff" />

MyCheckBox style

    <style name="MyCheckBox" parent="AppTheme">
        <item name="colorAccent">#ffff00</item> <--yellow
        <item name="android:textColorSecondary">#ff00ff</item> <--purple
    </style>

checked = true enter image description here

checked = false enter image description here

How to change the tick color

I have found many article on stackoverflow but doesn't work.

please help.

CodePudding user response:

Try This

<androidx.appcompat.widget.AppCompatCheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:text="hello123"
            app:buttonTint="@color/colorAccent"
            android:theme="@style/MyCheckBox"
            android:textColor="#ffffff" />

checked = true https://prnt.sc/CGSUxigv9pmF

checked = false https://prnt.sc/sAgExyOoSUvf

CodePudding user response:

you can try this

app:buttonTint="@color/colorAccent"

for reference

 <android.support.v7.widget.AppCompatCheckBox
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:checked="true"
      android:text="hello123"
      app:buttonTint="@color/colorAccent"
      android:theme="@style/MyCheckBox"
      android:textColor="#ffffff" />
  • Related