Justin Watkins Justin Watkins - 5 months ago 23
Android Question

How many times does ConstraintLayout 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?

Answer

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.