Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Constraint layout's width and height attributes automatically reset to 0dp

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

like image 859
P.C. Blazkowicz Avatar asked Jan 02 '17 00:01

P.C. Blazkowicz


People also ask

What does 0dp mean in constraint layout?

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.

What is the difference between 0dp and match parent?

match_parent means filling whats left where as 0dp means match constraints . In ConstraintLayout, match_parent is not supported. Save this answer.

What is the difference between constraint layout and linear layout?

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).

Which of the following constraint types expands a view only as much as needed to fit its contents?

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.


1 Answers

This bug report on Android issue tracker might be what you are looking for. If not I recommend submitting your own report.

like image 60
MidasLefko Avatar answered Sep 30 '22 19:09

MidasLefko