我们的数据库将颜色保存为String
就像“#AABBCC”,所以我基本上正在寻找这样的函数:Color.parseColor("#AABBCC");
对于颤振
Color 类需要这样的东西Color(0xFF42A5F5)
所以我需要转换"#AABBCC"
to 0xFFAABBCC
/// Construct a color from a hex code string, of the format #RRGGBB.
Color hexToColor(String code) {
return new Color(int.parse(code.substring(1, 7), radix: 16) + 0xFF000000);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)