I have a Column with 8dp vertical padding, and two...
# compose
g
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
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
What if you use
Modifier.preferredHeight
instead of
lineHeight
?
g
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)
}