문제

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?

도움이 되었습니까?

해결책

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top