问题描述
我试图了解颜色在 Android 中的工作原理.我将这种颜色设置为我的 LinearLayout
的背景,并且我得到了带有一些透明度的背景灰色:
I am trying to understand how colors work in Android. I have this color set as the background of my LinearLayout
, and I get a background gray with some transparency:
<gradient android:startColor="#b4555555" android:endColor="#b4555555"
android:angle="270.0" />
如果我删除最后两个字符 (55),我会得到纯色,失去透明度.我试图找到一个页面,我可以在其中看到有关此的一些解释,但我找不到它.
If I remove the last two characters (55) I get a solid color, losing the transparency. I was trying to find a page where I can see some explanation about this, but I couldn't find it.
推荐答案
如果您提供 6 个十六进制数字,则表示 RGB(红色、绿色和蓝色的每个值有 2 个十六进制数字).
If you provide 6 hex digits, that means RGB (2 hex digits for each value of red, green and blue).
如果您提供 8 个十六进制数字,则它是一个 ARGB(字母、红色、绿色和蓝色的每个值分别为 2 个十六进制数字).
If you provide 8 hex digits, it's an ARGB (2 hex digits for each value of alpha, red, green and blue respectively).
因此,通过删除最后的 55,您将从 A=B4、R=55、G=55、B=55(主要是透明的灰色)更改为 R=B4、G=55、B=55(a完全不透明的暗色小指).
So by removing the final 55 you're changing from A=B4, R=55, G=55, B=55 (a mostly transparent grey), to R=B4, G=55, B=55 (a fully-non-transparent dusky pinky).
请参阅颜色"文档,了解支持的格式.
See the "Color" documentation for the supported formats.
这篇关于了解 Android 上的颜色(六个字符)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!