parseColorString

fun String.parseColorString(format: ColorHexFormat = ColorHexFormat.ARGB): Int?

Parses a color string in either a hex (#RGB, #RGBA, #ARGB, #RRGGBB, #RRGGBBAA, or #AARRGGBB) or a named color (e.g., "red", "blue", etc.).

The default format is ColorHexFormat.ARGB, which is the same as Android's Color.parseColor. If you want to parse a color string in the RGBA format, use ColorHexFormat.RGBA.