ColorPicker
ColorPicker copied to clipboard
How do I get the hexadecimal equivalent of the color in onColorPicked?
Hi @rickyManalo you can convert the obtained color to Hexadecimal using: Integer.toHexString(color)
.
I'm using the following function, maybe it can help you too.
val hexColor = "#" + Integer.toHexString(color).substring(2).toUpperCase()
Log.d("CONVERTEDHEXCOLOR", "hexcolor: " + hexColor)
output:
CONVERTEDHEXCOLOR: hexcolor: #FF93A5
I already found that out. But it would be nice to have a built-in function for that thing because it's a really important data because we don't usually need what format the plugin gives to us on most cases.
Fixing Alpha issue String hexVal = String.format("#%06X", (0xFFFFFFFF & color)).toUpperCase();
int length=hexVal.length();
String withoutHash=hexVal.substring(1,length);
while (withoutHash.length()<=7)
{
withoutHash="0"+withH;
}
hexVal ="#"+withoutHash;