android - 如何从十六进制颜色字符串中获取颜色

标签 android colors hex

我想使用 "#FFFF0000" 等十六进制字符串中的颜色来(比如说)更改布局的背景颜色。 Color.HSVToColor 看起来像赢家,但它需要一个 float[] 作为参数。

我是否接近解决方案?

最佳答案

试试Color类方法:

public static int parseColor (String colorString)

来自 Android documentation :

Supported formats are: #RRGGBB #AARRGGBB 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray'

AndroidX:String.toColorInt()

关于android - 如何从十六进制颜色字符串中获取颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5248583/

相关文章:

vb.net - 禁用按钮上的实际文本颜色

android - 如何让所有应用程序的屏幕在android中只显示白色和黑色

C++17 十六进制浮点文字单精度后缀冲突?

android - 我怎样才能改变这个安卓布局?

android - 设备锁定时出现权限对话框

android - 在 Activity 恢复期间如何触发 fragment 的 onActivityResult

c - Arduino - 如何循环从 000000 到 FFFFFF 的十六进制颜色?

android - 选择后自定义微调器不隐藏下拉菜单

java - 更改字体颜色并使其带有下划线

Python:异或十六进制字符串