颜色值通常遵循RGB/ARGB标准,使用时通常以“#”字符开头,以16进制表示。前端开发中一般常用8位十六进制的数值代表颜色,其中前两位代表透明度(alpha),后两位分别代表(red)(green)(blue)十六进制色值(如#80FFFF00为半透明红色色值)。透明度分为256个等级,即 0 - 255,0就是透明,255就是不透明,对应着16进制 (透明)00 –> FF(不透明)。
- RGB颜色值与十六进制颜色码转换工具:RGB颜色值与十六进制颜色码转换工具
- 在react native开发中略有不同,半透明为
backgroundColor: 'rgba(0,0,0,0.5)'
- 在android开发中设置透明度
View v = findViewById(R.id.content);//找到你要设透明背景的layout 的id
v.getBackground().setAlpha(100);//0~255透明度值
v.setAlpha(100);//或者
一、常用的色值记录:
全透明 | #00000000 |
半透明 | #80000000 |
不透明 | #FF000000 |
白色半透明 | #80FFFFFF |
白色 | rgb(255,255,255) |
黑色 | rgb(0,0,0) |
红色 | rgb(255,0,0) |
绿色 | rgb(0,255,0) |
蓝色 | rgb(0,0,255) |
青色 | rgb(0,255,255) |
紫色 | rgb(255,0,255) |
二、各百分比透明度对应16进制值
100% | 00 |
99% | 03 |
98% | 05 |
97& | 07 |
96% | 0A |
95% | 0D |
94% | 0F |
93% | 12 |
92% | 14 |
91% | 17 |
90% | 1A |
89% | 1C |
88% | 1E |
87% | 21 |
86% | 24 |
85% | 26 |
84% | 29 |
83% | 2B |
82% | 2E |
81% | 30 |
80% | 33 |
79% | 36 |
78% | 38 |
77% | 3B |
76% | 3D |
75% | 40 |
74% | 42 |
73% | 45 |
72% | 47 |
71% | 4A |
70% | 4D |
69% | 4F |
68% | 52 |
67% | 54 |
66% | 57 |
65% | 59 |
64% | 5C |
63% | 5E |
62% | 61 |
61% | 63 |
60% | 66 |
59% | 69 |
58% | 6B |
57% | 6E |
56% | 70 |
55% | 73 |
54% | 75 |
53% | 78 |
52% | 7A |
51% | 7D |
50% | 80 |
49% | 82 |
48% | 85 |
47% | 87 |
46% | 8A |
45% | 8C |
44% | 8F |
43% | 91 |
42% | 94 |
41% | 96 |
40% | 99 |
39% | 9C |
38% | 9E |
37% | A1 |
36% | A3 |
35% | A6 |
34% | A8 |
33% | AB |
32% | AD |
31% | B0 |
30% | B3 |
29% | B5 |
28% | B8 |
27% | BA |
26% | BD |
25% | BF |
24% | C2 |
23% | C4 |
22% | C7 |
21% | C9 |
20% | CC |
19% | CF |
18% | D1 |
17% | D4 |
16% | D6 |
15% | D9 |
14% | DB |
13% | DE |
12% | E0 |
11% | E3 |
10% | E6 |
9% | E8 |
8% | EB |
7% | ED |
6% | F0 |
5% | F2 |
4% | F5 |
3% | F7 |
2% | FA |
1% | FC |
0% | FF |