Android 滚动recylerview时如何使recylerview上方的文本滚动

Android 滚动recylerview时如何使recylerview上方的文本滚动,android,android-layout,Android,Android Layout,我有一个布局,下面有标题textview和recylerview。 一切都很好。但我正在努力使整个东西可以滚动。这意味着,如果我在添加新项目时向下滚动rcylerview,我希望标题文本视图向上滚动消失,就像它是recylerview的一部分一样 这是我的xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/androi

我有一个布局,下面有标题textview和recylerview。 一切都很好。但我正在努力使整个东西可以滚动。这意味着,如果我在添加新项目时向下滚动rcylerview,我希望标题文本视图向上滚动消失,就像它是recylerview的一部分一样

这是我的xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"  xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

            <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:background="@null"
                    android:text="Near me"
                    android:textColor="@color/White"
                    android:textSize="21sp"
                    android:textStyle="bold" />

            <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
                android:id="@+id/swipeContainer"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/rvVideos"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
            </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

</LinearLayout>

我知道我可以伪造它,因此recylerview的项目1具有不同的布局,即标题文本,但我希望有更好的选择,这样我就不必处理项目数量和操作位置的边缘情况

您需要将textview和recycler视图包装在嵌套的ScrollView中

我希望这有帮助…干杯

您尝试过使用NestedScrollView吗?
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipe_refresh_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

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

                <TextView
                    android:id="@+id/textview"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"                   
                    android:text="Textview"
                    android:layout_marginTop="10dp"/>

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

            </LinearLayout>

        </android.support.v4.widget.NestedScrollView>

    </android.support.v4.widget.SwipeRefreshLayout>

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