How to convert android color format?

5.1k views Asked by At

I have a colorpicker dialog, where you can choose colors for a button, textcolor etc. If I log the choosen color, I get a -13459125 number which I dont know what RGB color is. I see that it's a 24-bit color code because 256*256*256 color can be selected, but how can I convert it to a format where I can define its RGB codes? I am not sure why it is negative either...

1

There are 1 answers

1
Tim On BEST ANSWER

Its packed 4-bytes to an integer as 0xAARRGGBB

Your value (-13459125), is 0xFF32A14B, or

A=255 R=50 G=161 B=75 in decimal.

If you have a color c, you can get the components with:

int red = Color.red(c)
int green = Color.green(c)

Etc