解決 scrollview 嵌套 recycleview 問題

需求:在scrollview 裏嵌套 recycleview ,recycleview不能滑動,可是它全部的條目還須要所有顯示出來,隨着scrollview 滑動html

解決:在recycleview 外嵌套一層relativeLayout,並 設置 android:descendantFocusability="blocksDescendants" 屬性,在activity中 給recycleview 設置setNestedScrollingEnabled(false);android

 

<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>
相關文章
相關標籤/搜索