在Android的了解颜色(6个字符)字符、颜色、Android

2023-09-11 12:40:34 作者:从此节操是路人

我想了解色彩的Andr​​oid是如何工作的。我有这种颜色设置为背景我的的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 couldn't find it.

这可能是一个初学者的问题,但我现在这个权利很感兴趣。

This may be a beginner's question, but I am intrigued by this right now.

推荐答案

如果您提供的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进制数字的Alpha,红色,绿色和蓝色的每个值分别)。

If you provide 8 hex digits, it's an ARGB (2 hex digits for each value of alpha, red, green and blue respectively).

因此​​,通过移除最后的55您是从改变= B4,R = 55,G = 55,B = 55(一个几乎透明灰色),以R = B4,G = 55,B = 55(一完全不透明的黑糊糊的小指)。

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).

查看颜色文档为支持的格式。

 
精彩推荐