gpt4 book ai didi

android - ConstraintLayout 与 RelativeLayout 性能 2020

转载 作者:行者123 更新时间:2023-12-03 13:34:15 26 4
gpt4 key购买 nike

我正在我的应用程序的各个屏幕上创建具有许多 View 的复杂布局。文档说:

It is a common misconception that using the basic layout structures leads to the most efficient layouts. However, each widget and layout you add to your application requires initialization, layout, and drawing. For example, using nested instances of LinearLayout can lead to an excessively deep view hierarchy. Furthermore, nesting several instances of LinearLayout that use the layout_weight parameter can be especially expensive as each child needs to be measured twice.



所以另一种选择是使用相对布局或约束布局。
This late 2018 article说相对布局更好。

今天在性能方面哪个更好?相对布局还是约束布局?

最佳答案

我会使用约束布局。它会表现得更好。

In the N release of Android, the ConstraintLayout class provides similar functionality to RelativeLayout, but at a significantly lower cost.



引自 performance/rendering/optimizing-view-hierarchies在底部

关于android - ConstraintLayout 与 RelativeLayout 性能 2020,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59628341/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com