在使用ScrollingView嵌套RecyclerView的过程往往会出现各种问题
1,滑动卡顿,滑动事件冲突
解决办法:
recyclerview.setHasFixedSize(true);
recyclerview.setNestedScrollingEnabled(false);
2,RecyclerView自适应高度
解决办法:RecyclerView外面套一层相对布局
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview_pinglinlist"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
3,ScrollingView自动滚动到列表项的位置
解决办法: 根布局设置: android:descendantFocusability="blocksDescendants"
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:background="#eee" />