android - ConstraintLayout 与 RelativeLayout 性能 2020

标签 android android-constraintlayout android-relativelayout

我正在我的应用程序的各个屏幕上创建具有许多 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/

相关文章:

Android:如何创建模态进度 "Wheel"叠加层?

android - 水平权重的 ConstraintLayout 问题

android - 约束布局左右约束

android - Android Studio约束未显示[Android Studio 3.1.3]

Android中心水平不起作用

android - 在 RelativeLayout 中垂直居中两个 TextView

Android Studio 没有显示任何与 Android 相关的选项

c# - 如何在 Xamarin Forms 中显示嵌套的项目列表?

android - 如何垂直对齐不同高度的 3 个 View

android - DisplayAlert 方法导致 xamarin.form 崩溃