Are there any APIs in compose text to change a tex...
# compose
s
Are there any APIs in compose text to change a text which spans let’s say two lines to look more “balanced” by making the lines take roughly the equal amount of space? I’m betting on “no”, but doesn’t hurt to ask 😄 Like instead of: Lorem ipsum dolor sit amet consectetur adipiscing elit Do: Lorem ipsum dolor sit amet consectetur adipiscing elit
z
If your text is centered, you could use a larger horizontal padding to get the same effect!
s
That could potentially work, but I also got a leading icon there, and then center-aligning the text but still having that left icon looks ugly as hell 😅
z
Yeah, thats probably not the best idea homer disappear If you dont mind sharing how the design looks, maybe thatll spawn some additional ideas!
Perhaps padding just to the right of the text would work? Something like 24/32.dp, but that might look odd on larger displays!
s
Yeap it does, and also in the “good” case where the line does fit on one line, then it sometimes makes it go to the next line making it ugly again 😄 So I’ll let it be like this until such an API is available (maybe never 😅)
s
We will soon add APIs for line breaking and balancing, however i am not sure if it would match to what you expect.
s
Could you give me some more details about what “line breaking and balancing” means? Specifically the balancing part is what I think I’d be looking for. If I understand it a bit better I can probably tell if it’s what I’m looking for or not.
c
In the good-old View system you could set android:breakStrategy on TextViews. It has simple, balanced and high_quality options https://stackoverflow.com/a/53237068
I guess @Siyamed refers to having something similar for Text Composables
s
Damn I had no idea such a thing existed, maybe until these APIs are available I can try going with an AndroidView to test this out 👀
s
Cc @Anastasia [G]
a
FYI @Andrei Ancuța