https://kotlinlang.org logo
#android
Title
# android
c

chi

06/28/2018, 6:48 PM
Converting the following to java snippet
backgroundPaint.setColor(0xffff0000);
to kotlin results in
backgroundPaint.color = -0x10000
. I wouldn't have been able to know how to get that hex color int on my own without the IDE conversion, please what is going on there so I can be able to reproduce it on my own?
l

Luke

06/28/2018, 6:51 PM
I think it's the same number written with a different literal
By which I mean: you can also write 0xffff0000
m

msink

06/28/2018, 6:53 PM
backgroundPaint.color = 0xffff0000.toInt()
l

Luke

06/28/2018, 6:57 PM
Yes, because if my understanding is correct, 0xffff0000 is the 2's complement of 0x10000, which represent the negation
c

chi

06/28/2018, 7:02 PM
Thanks @msink, but I don't want to cast, I want to write it directly as the IDE did. @Luke how can I be able to write my own, can you link me to some resource I can check to understand how to do that?
google 1