https://kotlinlang.org logo
i

Ian Warwick

01/09/2020, 2:55 PM
Not sure what I am doing wrong here but newing up a
Color
for Green shows up as Red in
@Preview
and in emulator? apologies if this is a known issue
c

Chuck Jazdzewski [G]

01/09/2020, 6:52 PM
What is the code in the
@Preview
function? Preview does not use the `Activity`'s
onCreate
.
i

Ian Warwick

01/09/2020, 6:53 PM
Sorry it happens in both preview and in app the code is equivalent, one sec
Copy code
@Composable
@Preview
fun WrongColor() {
    val color = Color(0f, 255f, 0f)

    Surface(color = color) {
        Container(width = 100.dp, height = 100.dp) {
            Text("Hello")
        }
    }
}
c

Chuck Jazdzewski [G]

01/09/2020, 7:16 PM
Definitely worth a bug report.
👍 1
i

Ian Warwick

01/09/2020, 7:16 PM
cool will do
m

matvei

01/10/2020, 4:31 PM
Haha, I tool a look. It turns out we have Float and Int overloads for Color constructor. Try removing
f
s from color components or substitute 255f with 1f, this might help
👍 1
Anyway, thanks very much for filing this, we will take a look into this ambiguity
🙏 1
2 Views