ScrollingView嵌套RecyclerView一系列问题

在使用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" /> 
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容