Issue
How to convert from Compose Color to Android Color Int?
I am using this code for the moment and it seems to be working, I can't seem to find a function to get the Int value of the color
Color.rgb(color.red.toInt(), color.green.toInt(), color.blue.toInt())
where Color.rgb
is a function android.graphics.Color
that returns an Integer color and color variable is just a Compose Color !
Since the float one requires higher API
Linked : How to convert android.graphics.Color to androidx.compose.ui.graphics.Color
Solution
The Android Compose Color
class now has function toArgb(), which converts to Color Int.
The function documentation says:
Converts this color to an ARGB color int. A color int is always in the sRGB color space. This implies a color space conversion is applied if needed.
-> No need for a custom conversion function anymore.
Answered By - Peter F
Answer Checked By - Katrina (JavaFixing Volunteer)