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

grandstaish

11/25/2020, 1:52 PM
I have a Column with 8dp vertical padding, and two text children. One text has a line height of 24sp, and the other 16sp. 8+24+16+8=56, yet the total height of the container is just under 60dp. Where exactly does the extra ~4dp come from?
l

loloof64

11/25/2020, 1:59 PM
Hi ! Are you using a Modifier for the Column ? Maybe its parameters are the cause ? Something like space child evenly, or space around (like in HTML flexbox) ?
a

André Kindwall

11/25/2020, 2:17 PM
What if you use
Modifier.preferredHeight
instead of
lineHeight
?
g

grandstaish

11/25/2020, 2:33 PM
There’s no extra spacing, the `Text`s are just larger than the line heights which is surprising to me. I want to understand exactly where this extra space comes from and what I can do about it. It’s going to be hard to match our designs otherwise
line height doesn’t work at all like I expected 🤔
Copy code
Column {
    val style = Theme.typography.body.copy(lineHeight = 48.sp)
    Text("ABCD", Modifier.background(Color.Yellow), style = style)
    Text("ABCD\nEFGH", Modifier.background(Color.Green), style = style)
}
5 Views