I can use `maxLines = 5` on a `Text` to limit it t...
# compose
m
I can use
maxLines = 5
on a
Text
to limit it to 5 lines, but how do I make it always take the space of 5 lines, even if there is less text? I'm looking for a
minLines = 5
, if there was one.
4
z
Also looking for an answer! I used a hack by appending X amount of \n to it so it always fills the space
m
I also ended up using a hack with
\n
. Would be nice to have a proper solution.
f
Not sure about
TextField
but in regular
Text
you can use lineHeight of your font to specify height of the text:
Copy code
maxLines = NumberOfLines,
modifier = modifier.height( // for min lines
    with(LocalDensity.current) { MyTextStyle.lineHeight.toDp() * NumberOfLines }
)
It still feels like a hack but less than inserting
\n
at the end of string 😄
w
@Marcin Wisniowski You can define a certain height in that case.
m
Yes but I don't know what's the height, because it depends on the text style, which may not be fixed.
Using line height seems better!