Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
RelativeLayout 测量其所有子级两次。这可能会导致性能问题。约束布局是否只测量其子项一次?
ConstraintLayout最多需要两次测量通过。
ConstraintLayout
如果您查看ConstraintLayout的源代码,您会看到它的方法首先在实用方法中onMeasure()测量其子项。internalMeasureChildren()接下来,它评估一些约束。最后,在循环中第二次ConstraintLayout调用它的孩子。child.measure()
onMeasure()
internalMeasureChildren()
child.measure()
源:反编译类文件,因为此时源不可用。