不能使用 ScrollView 包裹 ListView/GridView/ExpandableListVIew

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/BigBingtang/article/details/79423127

注意:官方明确禁止 ScrollView 包裹 ListView、GridView、ExpandableListVIew。因为这样会把 ListView 的所有 Item 都加载到内存中,要消耗巨大的内存和 cpu 去绘制图面。ListView 等 UI 组件自身有垂直滚动功能,也没有必要在嵌套一层 ScrollView。目前为了较好的 UI 体验,更贴近 Material Design 的设计,推荐使用 NestedScrollView。

如:

<android.support.v4.widget.NestedScrollView>
 <LinearLayout>
 <ImageView/>
 ...
 <android.support.v7.widget.RecyclerView/>
 </LinearLayout>
 </android.support.v4.widget.NestedScrollView>


猜你喜欢

转载自blog.csdn.net/BigBingtang/article/details/79423127