is it possible to set text to always occupy at lea...
# compose
m
is it possible to set text to always occupy at least 2 lines ?
j
“At least” sounds odd to my ears. How can you have very short text occupy more than one line? What if you have a one char word (e.g. “a”)? How would you split it in 2 lines?
t
I think he means a TextField with at least the height of 2 lines of text
😮 1
I would like to know, also 🙂
(Or maybe he meant the Text composable to have at least the height of 2 lines of text)
o
You could try experimenting with passing in a
lineHeight
, or set
maxLines
and pad your input text with a bunch of spaces but these are pretty hacky and not 100% correct. Another approach would be to set the Modifier.height property to be 2*`lineHeight` But the tradeoff here is it wouldn't work well if user scales text in settings.
m
@julioromano odd to your ears? It is pretty common in xml. You want a text to have the height of two lines, so if you have some text update, the layout won’t jump up and down based on layout positioning
j
Yepp I thought you were talking about the text itself, instead you’re talking about the text field 😛
r
I agree this would be a good feature. Right now I use
Modifier.height
as suggested above but it doesn't scale with text as noted. (Using
Modifier.verticalScroll
essentially takes care of this for my purposes though.)