解决 scrollview 嵌套 recycleview 问题

需求:在scrollview 里嵌套 recycleview ,recycleview不能滑动,但是它所有的条目还需要全部显示出来,随着scrollview 滑动

解决:在recycleview 外嵌套一层relativeLayout,并 设置 android:descendantFocusability="blocksDescendants" 属性,在activity中 给recycleview 设置setNestedScrollingEnabled(false);

 

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:descendantFocusability="blocksDescendants">

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            </android.support.v7.widget.RecyclerView>
        </RelativeLayout>
    </ScrollView>

  

  

posted @ 2018-12-12 15:30  IT_lss  阅读(1051)  评论(0编辑  收藏  举报