Android 中的 FrameLayout 内的最大 Children 视图数是多少?
What is the maximum number of Children Views inside a FrameLayout in Android?
我正在尝试使用 FrameLayout,其中包含多个 children。我知道通过使用 android:layout_gravity
属性我可以将多个 children 添加到 FrameLayout。但我不清楚的部分是,如果我向框架布局
大约80个是极限。
当您的布局中有太多视图时,您将得到以下 lint
AndroidLintTooManyViews
Description
Layout has too many views Using too many views in a single layout is bad
for performance. Consider using compound drawables or other tricks for
reducing the number of views in this layout. The maximum view count
defaults to 80 but can be configured with the environment variable
ANDROID_LINT_MAX_VIEW_COUNT.
请注意,由于不同设备的性能得分不同,所以不同设备的限制可能不同。
What is the maximum number of Children Views inside a FrameLayout in Android?
ViewGroup
在 docs. But you should try to lessen it as much as possible because it will take too long to render and it may cause your app to crash, throwing OutOfMemoryException or WhosebugException. It was also indicated here 上可以有多少 children 没有限制。
whether it is affecting to the performance side and Cost side of the app if I add more Children to the FrameLayout
添加更多的视图肯定会比添加更少的视图需要更多的时间来加载。我想正确的问题是,渲染视图的有效方法是什么? 嵌套视图效率低下,您应该始终尽量避免深层层次结构尽可能使用 ConstraintLayout
来实现。您可以阅读有关优化视图层次结构的更多信息 here。
我正在尝试使用 FrameLayout,其中包含多个 children。我知道通过使用 android:layout_gravity
属性我可以将多个 children 添加到 FrameLayout。但我不清楚的部分是,如果我向框架布局
大约80个是极限。
当您的布局中有太多视图时,您将得到以下 lint
AndroidLintTooManyViews
Description
Layout has too many views Using too many views in a single layout is bad for performance. Consider using compound drawables or other tricks for reducing the number of views in this layout. The maximum view count defaults to 80 but can be configured with the environment variable ANDROID_LINT_MAX_VIEW_COUNT.
请注意,由于不同设备的性能得分不同,所以不同设备的限制可能不同。
What is the maximum number of Children Views inside a FrameLayout in Android?
ViewGroup
在 docs. But you should try to lessen it as much as possible because it will take too long to render and it may cause your app to crash, throwing OutOfMemoryException or WhosebugException. It was also indicated here 上可以有多少 children 没有限制。
whether it is affecting to the performance side and Cost side of the app if I add more Children to the FrameLayout
添加更多的视图肯定会比添加更少的视图需要更多的时间来加载。我想正确的问题是,渲染视图的有效方法是什么? 嵌套视图效率低下,您应该始终尽量避免深层层次结构尽可能使用 ConstraintLayout
来实现。您可以阅读有关优化视图层次结构的更多信息 here。