06000
而不是#rrggbb,您应该使用rr,gg和bb的十六进制值0到F:
例如Color.parseColor(“#000000”)或Color.parseColor(“#FFFFFF”)
从文档:
public static int parseColor (String colorString):
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’, ‘grey’, ‘lightgrey’, ‘darkgrey’, ‘aqua’, ‘fuschia’,
‘lime’, ‘maroon’, ‘navy’, ‘olive’, ‘purple’, ‘silver’, ‘teal’
所以我相信如果你使用#rrggbb你的logcat中得到IllegalArgumentException
替代方案:
Color mColor = new Color();
mColor.red(redvalue);
mColor.green(greenvalue);
mColor.blue(bluevalue);
li.setBackgroundColor(mColor);