Reputation: 109
My understanding is that 4.4 changed some of the highlight colors for buttons to be grey or more neutral rather than blue. In my app I have some buttons which are a custom drawable - just a shape with rounded corners and then a selector for all the states. Now in my app so far I have just hard coded actual colors in this selector which are the same as from the default Holo theme on 4.0-4.3. However, with this recent change I want the pressed state of these buttons to be default (grey) when ran on 4.4+ devices. This way they will match the action bar highlights etc.
So far I have tried to use attribute 'colorPressedHighlight' in my selector but this doesn't work (I don't fully understand attributes/styles to be honest). The app wont compile, seemingly you can't refer to an attribute in place of a color.
Is there a way to do this? I'm now thinking maybe a different selector for each API version and just hard code the values in each? From a brief look I think this is possible, seems very inelegant though. This really shouldn't be as hard as it seems, right?
Any help much appreciated.
Upvotes: 1
Views: 358
Reputation: 2266
res / values-v19
Create value folder for API level 19 i.e for android 4.4 and above.
res/values-v19/colors.xml
define custom color value for button selection color
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name="button_selection"
>hex_color(Gray)</color>
</resources>
Create value folder for API level below 19 i.e for below android 4.4
res/values/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color
name="button_selection"
>hex_color(blue)</color>
</resources>
Then use this value in your custom drawable.
Upvotes: 2