Hex Colors in Android are some times 8 digits. How? What is the difference between #FFFFFF and #FFFFFF00

人盡茶涼 提交于 2019-11-26 15:57:00

问题


I sometimes have seen in examples where the coloring in Android is done as #FF191919. I mean a 8 digit hex number . But it should be only a 6 digit number. How are they related? If I want o convert a 6 digit number to a 8 digit number. How to do it? I mean convert #424242 to a 8 digit number coloring? Please let me know the details. Thank you for your time and help.


回答1:


The extra 2 digits are used to define the colors transparency, or alpha channel.

Android uses the ARGB format (or AARRGGBB as you use in your example)

For more (Android-specific) information take a look at the Color documentation




回答2:


The first two characters are representing the alpha (transparency) value, where FF is fully visible. This is known as aRGB.




回答3:


8-digit hex is an ARGB color. It is the same as usual RGB, but provides an extra alpha channel.

#RRGGBB in RGB is the same as #00RRGGBB in ARGB. Also take a look at Color.argb.




回答4:


the 8 digit color define with alpa level

let extract all we define hex color as 6 value pair of rgb 2 digit per

1st 2 digit for red, 2nd 2 digit for green and 3rd 2 digit for blue now if you want to set the alpha level of that then it define with the 8 digit as ARGB so, now 1st 2 digit value was define for the alpha and rest are for the RGB




回答5:


AN 8 digit Android HEx is called an aRGB. aRGB values are typically expressed using 8 hexadecimal digits, with each pair of the hexadecimal digits representing the values of the Alpha, Red, Green and Blue channel, respectively. For example 80FFFF00 represents 50.2% opaque (non-premultiplied) yellow. The 80 hex value, which is 128 in decimal, represents a 50.2% alpha value because 128 is approximately 50.2% of the maximum value of 255 (FF hex); to continue to decipher the 80FFFF00 value, the first FF represents the maximum value red can have; the second FF is like the previous but for green; the final 00 represents the minimum value blue can have (effectively – no blue). Consequently red + green yields yellow. In cases where the alpha is not used this can be shortened to 6 digits RRGGBB, this is why it was chosen to put the alpha in the top bits. Depending on the context a 0x or a number sign (#)[1] is put before the hex digits.



来源:https://stackoverflow.com/questions/6909896/hex-colors-in-android-are-some-times-8-digits-how-what-is-the-difference-betwe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!