How to change the color integer value to hex String on Android
Asked 2 years ago, Updated 2 years ago, 108 views
An integer value was generated in android.graphics.Color. The integer value is -16776961.
I'd like to change this value to #RRGGBB format for hexString. How shall I do it?
For example, I want to change -16776961 to #0000FFYo
String hexColor = String.format("#%06X", (0xFFFFFF & intColor));
You can do it in this way. %06x assigns the RRGGBB value to zero in hexadecimal format with 6 digits.