How to convert android color format?

…衆ロ難τιáo~ 提交于 2019-12-11 09:34:18

问题


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:


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



来源:https://stackoverflow.com/questions/10788858/how-to-convert-android-color-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!