In Android, RED (in Java) is defined as
@ColorInt public static final int RED = 0xFFFF0000;
When we assign to the value as below (in Kotlin), all good.
val value: Int = Color.RED
However when I replace
val value: Int = 0xFFFF0000
It will complaint
The integer literal does not conform to the expected type Int. How could I workaround it that I could still write in the ARGB format?
I know if we converted to signed Int as below, all works
val value: Int = -0x10000
But that will be too hard for me to recognize the color format value (i.e the FFFF0000 is referring to ARGB format).
User contributions licensed under CC BY-SA 3.0