Android中的颜色值一般遵循RGB/ARGB标准,使用时一般以“#”字符开头,以16进制表示。 经常使用的颜色值格式为:git
#RGB #ARGB #RRGGBB #AARRGGBB
其中,ARGB 依次表明透明度(alpha)、红色(red)、绿色(green)、蓝色(blue)。 以颜色值 #FF99CC00 为例,其中,FF 是透明度,99 是红色值, CC 是绿色值, 00 是蓝色值。spa
透明度分为256阶(0-255),计算机上用16进制表示为(00-ff)。透明就是0阶,不透明就是255阶,若是50%透明就是127阶(256的一半固然是128,但由于是从0开始,因此其实是127)。code
透明度 和 不透明度 是两个概念, 它们加起来是1,或者100%.orm
ARGB 中的透明度alpha,表示的是不透明度。依据来自维基百科中的定义。ci
The alpha channel is normally used as an opacity channel. If a pixel has a value of 0% in its alpha channel, it is fully transparent (and, thus, invisible), whereas a value of 100% in the alpha channel gives a fully opaque pixel (traditional digital images). Values between 0% and 100% make it possible for pixels to show through a background like a glass, an effect not possible with simple binary (transparent or opaque) transparency. It allows easy image compositing.开发
在开发过程当中,UI/UE给的标注图上,全部颜色值是RGB,可是透明度常常都是百分比,例如:颜色值:#FFFFFF,透明度40%。 使用过程当中咱们须要进行换算。以以前的值为例,换算过程以下:it
简单的换算,能够先将透明度,转换成不透明度,再根据下面的表格进行对应。io
100% — FF 95% — F2 90% — E6 85% — D9 80% — CC 75% — BF 70% — B3 65% — A6 60% — 99 55% — 8C 50% — 80 45% — 73 40% — 66 35% — 59 30% — 4D 25% — 40 20% — 33 15% — 26 10% — 1A 5% — 0D 0% — 00