Pergunta

Android color code is 8-digit hex code like #ff123456. First 2 digits are for opacity and rest of them are the general RGB color code. And the opacity value is optional assuming it is 0xff.

My question is, for a given color value, say:

<color name="vivid_red">#ffff0000</color>

Or

<color name="vivid_red">#ff0000</color>

Can I set a color with opacity 50% by referring a color value vivid_red, or should I define different color codes while their RGB parts are all the same, but only opacity parts are different?

Foi útil?

Solução

If it's XML, it will only be able to distinguish what you mean in your usage by the name of the element, unless you have some other code that parses the color element for a particular name attribute.

So,

<color name="vivid_red">#ff0000</color>

and

<color name="vivid_red_half_trans">#80ff0000</color>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top