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

Stylianos Gakis

08/24/2022, 8:51 AM
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

Zoltan Demant

08/24/2022, 9:33 AM
If your text is centered, you could use a larger horizontal padding to get the same effect!
s

Stylianos Gakis

08/24/2022, 9:36 AM
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

Zoltan Demant

08/24/2022, 9:45 AM
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

Stylianos Gakis

08/24/2022, 11:16 AM
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

Siyamed

08/24/2022, 1:32 PM
We will soon add APIs for line breaking and balancing, however i am not sure if it would match to what you expect.
s

Stylianos Gakis

08/24/2022, 1:34 PM
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

Csaba Szugyiczki

08/24/2022, 2:34 PM
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

Stylianos Gakis

08/24/2022, 2:40 PM
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

Siyamed

08/24/2022, 7:03 PM
Cc @Anastasia [G]
a

Anastasia [G]

08/30/2022, 11:35 AM
FYI @Andrei Ancuța
21 Views