Hi folks, anyone who could help me with Constraint...
# compose
j
Hi folks, anyone who could help me with ConstraintLayout ?
I'm trying to do following "row"... Basically text + new badge, + 2 icons. I can't figure out how to keep the text "wrap content" to keep the badge on right side, with having those 2 icons fully right aligned... And if the text is too long just to wrap to another line. My thinking was to create a horizontal chain with a spacer in the middle, which would be filling the space if any, but can't figure out how to set the rules. (I know how to do it multiple Rows, but for training I'd like to use ConstraintLayout). Anyone who would know how to do it ?
a
Why don't you simply use a row?
j
learning ConstraintLayout
r
No idea, I understand that you want to see how it works and have an alternative but personally wouldn't spend time there, there's no point in using Constraint Layout with Compose, its purpose is defeated with the new way of building UIs, as google stated:
In the View system,
ConstraintLayout
was the recommended way to create large and complex layouts, as a flat view hierarchy was better for performance than nested views are. However, this is not a concern in Compose, which is able to efficiently handle deep layout hierarchies.
Anyways, I'm still not sure what do you want to achieve, if I understood correctly you want text to be separated from badges and icons, the text starting from left side and badge and icons in the right side, right? Would be nice to see the output with
Row
system so anyone is able to help you instantly 🙂
j
what I want is
Text+Badge..................................Icon1+Icon2
instead of 1st and 2nd row... and 3rd/4th in case the text is long... (the "NEW" badge is optional based on state) ConstraintLayout is necessary in some cases so it's still good to know it...
a
While learning ConstaintLayout can be good, I don't think it's the right tool for the job in this use case.
j
well you need to start somehow with something simple...