Android5.0 checkbox Color Modification

Source: Internet
Author: User

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:

    1. colorcontrolnormal and colorcontrolactivated correspond to the color of frame control in normal state and active state respectively;
    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.