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

David W

01/09/2022, 8:15 AM
Is there a way to either change the center of a component or center a specific item in a row, with other items to either side of it? I'd like to make a specific word be the center of a Text, essentially.
The goal is to have the highlighted text be centered in each row.
I'm not on Android, so no ConstraintLayout
p

Paul Woitaschek

01/09/2022, 9:05 AM
What about using multiple columns and rows?
d

David W

01/09/2022, 4:35 PM
In what way? You can h-center a thing in a column, but not put anything to either side since it's a Column. And you can't h-center a specific thing in a Row.
f

Francesc

01/09/2022, 6:32 PM
You're probably better off writing a Layout so that you can measure and lay out the children as you need. You can only do so much with columns and rows.
d

David W

01/09/2022, 6:35 PM
Thank you, I looked into it and it's easier than I expected: https://developer.android.com/jetpack/compose/layouts/custom Still, probably not worth the time, I'll chuck it on my "wait until Compose is more mature" list 😄
hadn't even considered the possibility of a custom layout, assuming it would be harder than that
f

Francesc

01/09/2022, 6:39 PM
Yes, it's surprisingly simple, a welcome change from the view system's ViewGroup
c

Chris Sinco [G]

01/10/2022, 6:42 PM
Still, probably not worth the time, I’ll chuck it on my “wait until Compose is more mature” list
I don’t think this will necessarily be a “maturity” issue though as it’s a special case beyond Row/Column, and can be done relatively easily with a custom layout. Because of that, the priority of making this official or an added feature in Compose libraries is likely quite low since one can compose these things themselves for their specific use cases.
But, if you feel strongly that this should be part of Compose core layout libraries, please file a request on our tracker
d

David W

01/10/2022, 7:04 PM
I said that because this is a relatively trivial thing to do in Android using ConstraintLayout.
and I'm hoping that CL comes to CfD at some point
if not as first-party, then as a third-party library, which is still a "maturity" thing, building up that ecosystem of libraries
c

Chris Sinco [G]

01/11/2022, 3:57 AM
Gotcha. I'm hoping as well though the team is a bit constrained at the moment (no pun intended)
😆 1
4 Views