I'd like to use a color from an hexa string such as "#FFFF0000"
to (say) change the background color of a Layout. Color.HSVToColor
looks like a winner but it takes a float[]
as a parameter.
Am I any close to the solution at all?
Hex color codes start with a pound sign or hashtag (#) and are followed by six letters and/or numbers. The first two letters/numbers refer to red, the next two refer to green, and the last two refer to blue. The color values are defined in values between 00 and FF (instead of from 0 to 255 in RGB).
A color hex code is a hexadecimal way to represent a color in RGB format by combining three values – the amounts of red, green and blue in a particular shade of color. These color hex codes have been an integral part of HTML for web design, and remain a key way of representing color formats digitally.
Try Color
class method:
public static int parseColor (String colorString)
From Android documentation:
Supported formats are: #RRGGBB #AARRGGBB 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', 'yellow', 'lightgray', 'darkgray'
AndroidX: String.toColorInt()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With