Before Compose, when creating complex UI with XML, it's recommended to avoid nesting views (RelativeLayout
and LinearLayout
), and encouraged to use ConstraintLayout
for achieving complex layouts.
Now Compose has come out, and just by looking at it, ConstraintLayout
in Compose was so complicated to understand, from my perspective—it's taking more time to figure out how the view should look like with ConstraintLayout
than with nested Column
and Row
.
Honestly, I'd rather go with nested Column
and Row
than ConstraintLayout
in Compose, but I'm not sure about its drawbacks.
Short answer: No, nested Row
s/Column
s should be fine.
Compose is designed to reduce the penalty for nesting layouts, and allow for layouts to be more easily...well, composed. The View system requires non-trivial overhead for each View
you create, so it was encouraged to avoid nesting them more than necessary and creating extra View
s.
While it's hard to say that there are no situations in which nesting Row
s and Column
s will cause a performance problem where ConstaintLayout
would work well, you shouldn't immediately jump to ConstraintLayout
when using nested Row
s/Column
s would allow you to more easily express your desired layout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With