What is the default color? Attr / colorControlHighlight in android?

I need to know the default color: attr / colorControlHighlight in android, because I need to apply the same color as my buttons, click the background state in my pre-leopty devices.? attr / colorControlHighlight is one of the lollipop attributes that cannot be used on pre lollipop, otherwise it will cause an error.

+6
source share
1 answer

?attr/colorControlHighlight is a reference to the colorControlHighlight value defined in attr xml.

attrs.xml is a file located in:

android_sdk \\ platform android-22 \ data \ res \ values ​​\ attrs.xml

All attributes that you can use in your application are listed here.

If we check this file, we will find

<attr name="colorControlHighlight" format="color" /> string,

which means that colorControlHighlight itself is a reference to color.

And all the attributes declared here are just references to other values. Actual values ​​are assigned in the themes.xml file, which, in turn, is located in:

Android SDK \\ platform android-22 \ data \ Res \ values ​​\ themes.xml

If we check this file, we will find that there are many themes that use our colorControlHighlight link. Thus, regardless of whether you use any theme in the application, the values ​​of colorControlHighlight will be different for each of them.

In our case, there are 2 topics:

<item name="colorControlHighlight">@color/legacy_button_pressed</item> for the topic

and

<item name="colorControlHighlight">@color/legacy_light_button_pressed</item> for Theme.Light

Here we see other links instead of values. But now they relate to the color attribute: @color/ . So we need to go to the color.xml files.

it

Android SDK \\ platform android-22 \ data \ res \ values ​​\ colors.xml

Android SDK \\ platform android-22 \ data \ res \ values ​​\ colors_holo.xml

Android SDK \\ platform android-22 \ data \ Res \ values ​​\ colors_leanback.xml

Android SDK \\ platform android-22 \ data \ res \ values ​​\ colors_legacy.xml

Android SDK \\ platform android-22 \ data \ res \ values ​​\ colors_material.xml

A simple file check reveals the actual values ​​we were looking for:

in colors-legacy.xml file :

<color name="legacy_button_pressed">#fffea50b</color>

and

<color name="legacy_light_button_pressed">@color/legacy_button_pressed</color> which also refers to the first color.

So the color we were looking for was # fffea50b

+19
source

All Articles