What is the default color of ?attr/colorControlHighlight in android?

前端 未结 1 1763
醉话见心
醉话见心 2021-02-20 11:06

I need to know the default color of ?attr/colorControlHighlight in android because I need to apply the same color for my buttons press state background in my drawable for pre lo

1条回答
  •  梦毁少年i
    2021-02-20 11:40

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

    attrs.xml is a file located in:

    android_sdk\platforms\android-22\data\res\values\attrs.xml

    Here, all of the attributes, that you may use in your app, are located.

    If we check that file, we will find

    string,

    which means that colorControlHighlight itself is a reference to a color.

    And all attributes declared here are just references to another values. The actual values are assigned in themes.xml file, which, in it's turn, is located in:

    android-sdk\platforms\android-22\data\res\values\themes.xml

    If we check that file, we'll find, that there are a lot of themes, which are using our colorControlHighlight reference. So whether you are using one theme or another in your application, the colorControlHighlight values would be different for each of them.

    In our case there are 2 themes:

    @color/legacy_button_pressed for Theme

    and

    @color/legacy_light_button_pressed for Theme.Light

    Here we see another references instead of values. But now they refer to the color attribute: @color/. Thus we need to move to the color.xml files.

    These are

    android-sdk\platforms\android-22\data\res\values\colors.xml

    android-sdk\platforms\android-22\data\res\values\colors_holo.xml

    android-sdk\platforms\android-22\data\res\values\colors_leanback.xml

    android-sdk\platforms\android-22\data\res\values\colors_legacy.xml

    android-sdk\platforms\android-22\data\res\values\colors_material.xml

    Simple file check brings out the actual values we were looking for:

    in the colors-legacy.xml file:

    #fffea50b

    and

    @color/legacy_button_pressed which also refers to the first color.

    So, the color we searched for, was #fffea50b

    0 讨论(0)
提交回复
热议问题