ConstraintLayout 测量它的每个 children 多少次?

How many times does ConstraintLayout measure each of its children?

RelativeLayout 测量其所有 children 两次。这可能会导致性能问题。约束布局是否只测量其 children 一次?

ConstraintLayout 最多需要两次测量。

如果您查看 ConstraintLayout 的源代码,您会发现它的 onMeasure() 方法首先在 internalMeasureChildren() 实用方法中测量其子项。接下来,它评估一些约束。最后,ConstraintLayout 在循环中第二次对其子项调用 child.measure()

来源:反编译了 class 个文件,因为此时没有来源。