嵌套滚动视图中的 Recyclerview

Recyclerview inside nestedscrollview

我有这样的布局

文本视图 1

文本视图 2

TextView 3

ImageView

Recyclerview

[项目 1 到 10 垂直组织]

现在,当我滚动页面时,整个页面都必须滚动,而不仅仅是 Recyclerview。 这是 android 中非常常见和古老的事情,我得到的解决方案是实施
Is there an addHeaderView equivalent for RecyclerView?

我不想采用这种方法,因为它是一种非常老套的解决方案。我觉得在 nestedscrollview 中实现 recyclerview 可能会解决我的问题,我采取的方法是否正确?还是我应该使用协调器布局? 非常感谢任何帮助,您能否也提供一些符合我要求的链接。?

我找到了这个查询的解决方案。看看这个布局, 这个想法是有一个

CoordinatorLayout 作为根

--AppBar布局恰好是Coordinator的直接子布局

托管将具有不同 textview/radiobutton 的相对布局(您想要添加为页眉之类的东西)

---关闭appbarlayout

在应用栏布局下方添加 recyclerview。

它会工作正常,检查我使用的布局,不要忘记在适当的地方添加 app:behavior。

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                                     android:layout_width="match_parent"
                                                     xmlns:app="http://schemas.android.com/apk/res-auto"
                                                     android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
                android:layout_height="wrap_content"
                android:layout_width="match_parent">

        <RelativeLayout
                android:layout_width="match_parent"
                app:layout_scrollFlags="scroll|enterAlways"
                android:layout_height="wrap_content"
                android:id="@+id/relLayout">
            <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:text="Large Text"
                    android:id="@+id/textView"
                    android:layout_marginLeft="97dp"
                    android:layout_alignParentTop="true"
                    android:layout_alignParentLeft="true"
                    android:layout_marginTop="37dp"/>

                <RadioButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="New RadioButton"
                        android:id="@+id/radioButton"
                        android:layout_below="@+id/textView"
                        android:layout_alignLeft="@+id/textView"
                        android:layout_marginTop="49dp"/>
            </RelativeLayout>
        </android.support.design.widget.AppBarLayout>

     <android.support.v7.widget.RecyclerView
           app:layout_behavior="@string/appbar_scrolling_view_behavior"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:layout_marginTop="@dimen/padding_small"
             android:layout_below="@+id/relLayout"
             android:id="@+id/recyclerview_settings_list"
             android:scrollbars="vertical"/>

</android.support.design.widget.CoordinatorLayout>