Android 顏色透明度對應的十六進位制表格 + Android版本對應級別表格
阿新 • • 發佈:2018-12-23
一、顏色透明度和十六進位制對應的表格:
透明度 | 16進位制 |
100% | 0 |
99% | 3 |
98% | 5 |
97% | 7 |
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 |
(1)100% 透明度表示完全透明,不透明度為0,對應十六進位制00
(2)0% 透明度表示完全不透明,不透明度為255,對應十六進位制FF
(3)表裡的值為向上取整。
如50%透明度,不透明度為 255*50% = 127.5,向上取整為128,對應十六進位制80。
在一些表裡50%對應7F,則是採用的向下取整,對應十進位制127。
使用方法:
在六位顏色色值前面加上對應的十六進位制即可,例:
<color name="halfBlack">#80000000</color> <color name="eightyPercentRed">#33FF0000</color> <color name="transparent">#00000000</color>
分別代表 50% 透明的黑色,80% 透明的紅色,完全透明
二、Android版本對應級別表格:
級別 | 版本 | 代號 |
1 | 1 | (無代號) |
2 | 1.1 | (無代號) |
3 | 1.5 | Cupcake |
4 | 1.6 | Donut |
5 | 2 | Eclair |
6 | 2.0.1 | Eclair |
7 | 2.1 | Eclair |
8 | 2.2.x | Froyo |
9 | 2.3 - 2.3.2 | Gingerbread |
10 | 2.3.3 - 2.3.7 | Gingerbread |
11 | 3 | Honeycomb |
12 | 3.1 | Honeycomb |
13 | 3.2.x | Honeycomb |
14 | 4.0.1 - 4.0.2 | Ice Cream Sandwich |
15 | 4.0.3 - 4.0.4 | Ice Cream Sandwich |
16 | 4.1.x | Jelly Bean |
17 | 4.2.x | Jelly Bean |
18 | 4.3.x | Jelly Bean |
19 | 4.4 - 4.4.4 | KitKat |
21 | 5 | Lollipop |
22 | 5.1 | Lollipop |
23 | 6 | Marshmallow |
24 | 7 | Nougat |
25 | 7.1 | Nougat |
26 | 8.0.0 | Oreo |
27 | 8.1.0 | Oreo |
級別從1遞增,代號首字母從C開始遞增
使用方法:
例如,判斷Android版本是否大於等於Android6.0:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { }