Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: java.lang.IllegalArgumentException: Unknown color

Tags:

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

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

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...

like image 442
Anna Lam Avatar asked Nov 22 '11 10:11

Anna Lam


Video Answer


1 Answers

From documentation:

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'

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

like image 69
Vito Gentile Avatar answered Oct 14 '22 15:10

Vito Gentile