Reputation: 1573
I'm trying to understand something about this method, setBackgroundColor(int) in android.
I keep seeing people say that to use it with hex values, you should do
0xFF000000 + 0x[6 digit hex value that you want]
But, and correct me if I'm wrong, isn't 0xFFFFFFFF, a legal input to the function, larger than the maximum size of an integer? Why am I allowed to put it in as input? Is it because of two's complement cutting the max size of integers in half?
Upvotes: 0
Views: 738
Reputation: 28823
This is not #RRGGBB
format. Its actually 0xAARRGGBB
format.
AA is for transparency (Alpha). And RR is the red, GG is the green, and BB is the blue component. This is hexadecimal, so the values range from 00 to FF (255).
You can also refer to: Why is Java able to store 0xff000000 as an int?
Upvotes: 2