Reputation:
I am facing an Issue converting Hex color #000
to Color
or RGB
. Android Color.parseColor
doesn't support shortened hex code.
Please suggest the best solution.
Upvotes: 0
Views: 253
Reputation: 628
I think best way is
int red = colorString.charAt(1) == '0' ? 0 : 255;
int blue = colorString.charAt(2) == '0' ? 0 : 255;
int green = colorString.charAt(3) == '0' ? 0 : 255;
Color.rgb(red, green,blue);
Upvotes: 1