1、ScrollView嵌入RecyclerView的处理
用NestedScrollView替代ScrollView,如下布局:
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bgWhite"
android:fillViewport="true">
<LinearLayout
android:id="@+id/rl_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
...
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_ofen_buy"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView
注意android:fillViewport这个属性,运行NestedScrollView里面的组件填充它。
2、RecyclerView的多布局
https://github.com/drakeet/MultiType/wiki/Android-MultiType-3.0
3、RecyclerView的刷新
相比ListView的刷新notifyDataSetChanged(),RecyclerView额外增加了如下的一些刷新方法:
notifyItemChanged(int position)
notifyItemChanged(int position, Object payload)
notifyItemRangeChanged(int positionStart, int itemCount)
notifyItemRangeChanged(int positionStart, int itemCount, Object payload)
notifyItemRemoved(int position)
notifyItemRangeRemoved(int positionStart, int itemCount)
notifyItemInserted(int position)
notifyItemRangeInserted(int positionStart, int itemCount)
notifyItemMoved(int fromPosition, int toPosition)
本文介绍了如何使用NestedScrollView替代ScrollView来解决嵌套RecyclerView时的问题,并提供了实现代码示例。此外,还介绍了RecyclerView的多布局设置及各种刷新方法。
1045

被折叠的 条评论
为什么被折叠?



