- Color(int value);前缀
0xff
Color(0xffff4d03) // 六进制颜色`#ff4d03`
透明度
0x后面跟着前2个ff一般代表透明度,而ff本身就代表不透明
static const defaultBackgroundColor = const Color(0xFF8B5FFE);
static const defaultActiveBackgroundColor = const Color(0xB38B5FFE);
static const defaultDisabledBackgroundColor = const Color(0x338B5FFE);
00%=FF(不透明) | 5%=F2 | 10%=E5 |
15%=D8 | 20%=CC | 25%=BF |
30%=B2 | 35%=A5 | 40%=99 |
45%=8c | 50%=7F | 55%=72 |
60%=66 | 65%=59 | 70%=4c |
75%=3F | 80%=33 | 85%=21 |
90%=19 | 95%=0c | 100%=00(全透明) |
方法
-
Color.fromARGB(int a, int r, int g, int b)
-
Color.fromRGBO(int r, int g, int b, double opacity)
-
withAlpha(int a)
-
withOpacity(double opacity)
// 1、先随便赋一个色值
Color color = Color(0xffff4d03);
// 2、设置他的透明度
color.withOpacity(0.1);