0

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.

AskNilesh
  • 67,701
  • 16
  • 123
  • 163

1 Answers1

1

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);
GTID
  • 538
  • 2
  • 6
  • 19