Reputation: 4386
I have a ListView, and I want the items to show a different color than Holo Blue when they're pressed. So I made a selector drawable and it works great.
My color is FFF100
, a nice yellow.
However, I think it's a bit too saturated, so I want to bring down the alpha to make it more like my tab indicator, which is done with an image file. It has the same color, FFF100
, but with 50% opacity.
So I changed my color to an ARGB value, using 80
(128/255) as the alpha value. So my color is now 80FFF100
.
But now it looks like a weird green!
And my colors.xml:
<resources>
<color name="putio_accent">#FFF200</color> **This is the standard yellow color. Using this works fine, but it's too saturated, like I said before.
<color name="putio_accent_selected">#80FFF100</color> **This should be the same, but with 50% alpha..
</resources>
Why is this happening?!
Upvotes: 0
Views: 323
Reputation: 4386
Fixed it. The reason it was showing up green was because for some reason, Android was showing the default pressed color (Holo blue) and combining it with mine. Blue + yellow = green!
I fixed it by taking out this line in my row's XML:
android:background="@drawable/putio_clickable_bg"
and putting this line into my ListView:
android:listSelector="@drawable/putio_tab_indicator"
Why this fixes it, I don't know. Maybe it's a bug in Android?
Upvotes: 1
Reputation: 157
Not sure why it's doing that exactly without seeing code, but you could always just convert your ARGB color to RGB, using this: foreground * alpha + background * (1-alpha)
Or take a snapshot and yank the color directly (which would change the color you want to f7f077). Of course if your background is not solid, then you can't do this, but from your picture that doesn't appear to be the case.
Upvotes: 1
Reputation: 12335
I'm not aware of what really happens when you use other numbers like '80' in the alpha columns. I have only used '00', try that as this gives a perfect colour with about 50% opacity. It appears that not using 0s changes the colour.
Hope this helps.
Upvotes: 0