Hi Kotlin folks! I’m trying to parse a hexadecimal...
# announcements
c
Hi Kotlin folks! I’m trying to parse a hexadecimal color. Input is
String
like
"0xFF3F51B5"
and I need to use it in
button.setBackgroundColor(int: Int)
. I’ve tried
Integer.decode(hexString)
and
hexString.toInt(radix = 16)
but no success. Looks like there’s an overflow: https://youtrack.jetbrains.com/issue/KT-4749 Please help. Thanks 🙂
m
The largest an
Int
can hold is 7FFFFFFF. What’s the source of your string? It looks like it might be “Red Green Blue alpha” - but probably the button doesn’t accept alpha?
c