Search code examples
androidcheckboxandroid-5.0-lollipopmaterial-designandroid-appcompat

Appcompat v7 Material checkbox changing color to default black in Lollipop devices


I am using appcompat v7 material checkbox. My project theme is light blue, so I am assigning light blue for my checkbox checked color in styles.xml as follows

<!--checked color-->
<item name="colorAccent">@color/light_blue</item> 

<!--un checked color--> 
<item name="android:textColorSecondary">@color/secondary_text</item>  

In My layout file

    <CheckBox
        android:id="@+id/chk_tick"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:button="@drawable/abc_btn_check_material"
        android:layout_gravity="center"/>

Everything works fine with the versions below kitkat's, but the problem arises only with lollipop versions ( By default it is automatically assigning black color ). I really dont know why it is happening. Kindly please help me with your solutions. Thanks in advance


Solution

  • Remove this line:

    android:button="@drawable/abc_btn_check_material"

    Your CheckBox should be styled automatically, without setting android:button property.