Justin Watkins Justin Watkins - 4 months ago 12
Android Question

How many times does constrain layout measure each of its children?

RelativeLayout measures all its children twice. This can cause performance issues. Does constraint layout only measure its children once each?


ConstraintLayout requires two measure passes.

If you look at the ConstraintLayout's source, you'll see that its onMeasure() method first measures its children inside an internalMeasureChildren() utility method. Next, it evaluates some constraints. Finally, ConstraintLayout calls child.measure() on its children a second time inside a loop.