I find myself sorely missing ConstraintLayout in C...
# compose
e
I find myself sorely missing ConstraintLayout in Compose, but I have some concerns about using the Compose version of it. Anyone else feel the same way? More details in the thread.
I've been playing around with Compose the past few weeks, and while I definitely prefer it over the old View system, I'm having trouble adjusting to laying things out in Rows and Columns. I've been using ConstraintLayout since early alphas, and I quickly adopted to use it as my default ViewGroup, even when a simple LinearLayout would have sufficed (sometimes even instead of FrameLayout). My reasoning for this was: Designs change constantly (in my world) and what is easy with a LinearLayout one day might be difficult the next. ConstraintLayout has proven to be more than flexible enough to address hundreds of these scenarios 2. I (still) find it fun to use 3. The flat hierarchy helps performance (not as relevant anymore) 4. ConstraintLayout has less cognitive load when reading and writing; it's easier to reason about why something is where it is (this may vary by the person) 5. It's easier to build a reactive layout I know that you're able to use ConstraintLayout with Compose, but it still feels a little clunky (I'm sure the ergonomics are being worked on), and I get the feeling from the documentation that it's less preferable to use it. Another concern is performance. I know there's no gain in Compose because complex hierarchies don't have the same issue as the View system. Is there a performance loss though due to recomposition, and the tree having wider instead of deeper paths? My last issue with using it is that it's currently Android only (and I've been playing around with multiplatform Compose a lot lately). I think I saw some discussions about working to remove Android dependencies from ConstraintLayout, but I don't know the status of it.
t
I never liked ContraintLayout because it makes it much harder to move components around. If you have a complexe layout and want to move one component you have to fix all anchor ids. It is the same for old view system and compose. But the good think is you can do it as you like. Performance is not really better in constraint layout. Because it depends on the complexity. It does not make a big difference how you implement it. And also when it really is a problem you have to measure to be sure constraint layout is better.
e
Interesting. I've had the same mechanics but an opposite experience when moving components around. In a complex layout with ConstraintLayout I just change a few anchors and not much else. In a row/column based system I have to start unwrapping layers and/or move them around. I guess it comes down to internal mental wiring in that sense.
👍 2