I need to convert an string to Color my api response is this "mainColor": "#8439FF"
, i need to transformit to Color
i have tried the next solutions
int color = Color.parseColor(mainColor);
val string = mainColor
val ColorPrimario = string.replaceFirst("^#".toRegex(), "").toInt(16)
the problem whit this solutions is that the result its an int not Color, and it marks error for that reason. any help would be appreciated
-------------Edit-------------
I have solved the problem i did it this way
val string = mainColor
val color = Color(string.toColorInt())