core-ktx / androidx.graphics / kotlin.String / toColorInt

toColorInt

inline fun String.toColorInt(): Int

Return a corresponding Int color of this String.

Supported formats are:

#RRGGBB
#AARRGGBB

The following names are also accepted: "red", "blue", "green", "black", "white", "gray", "cyan", "magenta", "yellow", "lightgray", "darkgray", "grey", "lightgrey", "darkgrey", "aqua", "fuchsia", "lime", "maroon", "navy", "olive", "purple", "silver", "teal".

Exceptions

IllegalArgumentException - if this String cannot be parsed.