Android:java.lang.IllegalArgumentException:未知颜色 [英] Android: java.lang.IllegalArgumentException: Unknown color

查看:403
本文介绍了Android:java.lang.IllegalArgumentException:未知颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试运行以下代码时出现上述错误:

I'm getting the above error when I try to run the following code:

int colourInt = Color.parseColor(colour.getHexValue());

有问题的十六进制值为ee3090b0.有没有办法将彩色十六进制值转换为等效的整数并仍然保留alpha值? 我已尝试遵循此 post 中的建议,但这不起作用...

The offending hexadecimal value is ee3090b0. Is there a way I can convert a colour hexdecimal value to its integer equivalent and still retain the alpha value? I've tried following a suggestion made in this post, but it isn't working...

推荐答案

来自

公共静态int parseColor(字符串colorString)

public static int parseColor (String colorString)

解析颜色字符串,并返回相应的color-int.如果 字符串无法解析,引发 IllegalArgumentException 异常. 支持的格式为:#RRGGBB #AARRGGBB'红色','蓝色','绿色', '黑色','白色','灰色','青色','品红色','黄色','浅灰色', 'darkgray'

Parse the color string, and return the corresponding color-int. If the string cannot be parsed, throws an IllegalArgumentException exception. Supported formats are: #RRGGBB #AARRGGBB 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray'

您的方法可能返回的字符串不是以#开头的字符串.

Your method probably returns a string that doesn't start with a #.

这篇关于Android:java.lang.IllegalArgumentException:未知颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆