Android5.0, the checkbox has a material design animation effect with the default style as shown:
As you can see, in, the checkbox has a gray border, and when selected, the fill color is green.
So if we want to change the border and fill color, but also save material design animation effect, what should be done.
Add a new article in the Style.xml file:
name="My_CheckBox" parent="@android:style/Widget.Material.CompoundButton.CheckBox"> <item name="android:colorControlActivated">@color/colorAccent</item> <item name="android:colorControlNormal">@color/colorPrimary</item></style>
Then, set the checkbox:
<CheckBox android:id="@+id/save_pass" android:layout_width="wrap_content" android:layout_height="wrap_content" android:theme="@style/My_CheckBox"/>
It is important to note that:
- colorcontrolnormal and colorcontrolactivated correspond to the color of frame control in normal state and active state respectively;
- When you set a style for a checkbox, you need to use it with
android:theme="@style/My_CheckBox" style="@style/My_CheckBox" no effect.
I use Android Studio version 2.2.3, the Android version on the phone is 5.0.2.
Android5.0 checkbox Color Modification