如何在滚动视图中滚动RecyclerView

Adi*_*yad 1 xml android scrollview android-recyclerview

在此处输入图片说明

如何在scrollview中的RecyclerView上方滚动

我必须在scrollview显示中实现RecyclerView,如下代码,但不是滚动RecyclerView。

请给答案

            <ScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/horizontalScrollView"
            android:layout_marginTop="10dp">

          <RelativeLayout...

                        <android.support.v7.widget.RecyclerView
                            android:id="@+id/rvpouch"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:nestedScrollingEnabled="false"
                            android:layout_below="@+id/textView3">


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

                    </RelativeLayout>

        </ScrollView>
Run Code Online (Sandbox Code Playgroud)

Fer*_*med 6

不要RecyclerView在里面使用ScrollView。使用NestedScrollView代替ScrollView

NestedScrollView就像一样ScrollView,但是它在新版和旧版Android上都同时充当嵌套滚动父级和子级。默认情况下启用嵌套滚动。

例如:

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:descendantFocusability="blocksDescendants">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView_one"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:nestedScrollingEnabled="false">

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

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView_two"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:nestedScrollingEnabled="false">

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

        <android.support.v7.widget.RecyclerView
            android:id="@+id/recyclerView_three"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:nestedScrollingEnabled="false">

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

    </LinearLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)

使用属性android:nestedScrollingEnabled="false"进行平滑滚动。