https://kotlinlang.org logo
#compose
Title
# compose
g

Geert

11/10/2020, 10:35 AM
I was changing the color of a Text, but what is the difference between both color values?? It can be set by the Text, but also by TextStyle???
Copy code
Text(
                color = Color.White,
                text = "Verwijder Alles",
                textAlign = TextAlign.Center,
                modifier = Modifier.padding(16.dp),
                style = TextStyle(
                    color = Color.White,
                    fontSize = TextUnit.Sp(20),
                    fontWeight = FontWeight.Bold
                ),
            )
n

nrobi

11/10/2020, 10:39 AM
I suppose that the color is for the whole composable while the other specifically for the text, that is to be drawn
In practice however I'm not sure how that resolves
a

Anastasia [G]

11/10/2020, 10:49 AM
The separate parameters are here for the convenience. Often you just want to change only a color, so you don’t need to create the whole TextStyle object to do just that. The order is the following: It’ll first try to get color from the color parameter. If it’s not supplied, it’ll fall back to TextStyle’s color. If neither is provided, it’ll fallback to the content color.
👍 2