解决 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>

  

  

猜你喜欢

转载自www.cnblogs.com/IT-lss/p/10108678.html