So I have this weird and annoying problem about constraint layouts - some of the views inside Constraint layout change width and height to 0dp from custom value WITHOUT ASKING OR NOTIFYING. This behavior is not consistent as well because I will build my layouts, I will test them, I will be happy and move on to a next thing, but then hours later I will see that the values are set back to 0dp and layouts are all messed up. Good thing that uncommitted files in android studio turn blue, so I can simply notice this undesired changed and ctrl+z
I have just recently starting implementing and converting variety of layouts to constraint layouts, so there might something that I have missed out? Does anyone what could be a cause of this very undesired behavior?
My layout structure is this
Root - Constraint Layout
views
views
ViewPager
Constraint Layout
Constraint Layout
Constraint Layout
Constraint layout does include another constraint layouts but I don't think that should cause any issues
Edit: I am currently using Android Studio 3.0 Canary 7, developing much more complex layouts and I this issue have not occurred since upgrading to 3.0
for the children of ConstraintLayout if you have set constraints then the 0dp is for match_constraint (take full width, or full height) Using 0dp, which is the equivalent of "MATCH_CONSTRAINT" https://developer.android.com/reference/android/support/constraint/ConstraintLayout.
match_parent means filling whats left where as 0dp means match constraints . In ConstraintLayout, match_parent is not supported. Save this answer.
Following are the differences/advantages: Constraint Layout has dual power of both Relative Layout as well as Linear layout: Set relative positions of views ( like Relative layout ) and also set weights for dynamic UI (which was only possible in Linear Layout).
Wrap Content: The view expands only as much as needed to fit its contents. spread: Expands the view as much as possible to meet the constraints on each side. This is the default behavior.
This bug report on Android issue tracker might be what you are looking for. If not I recommend submitting your own report.
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