Android scrollview内部的视图不';在滚动recyclerview时不要滚动

Android scrollview内部的视图不';在滚动recyclerview时不要滚动,android,android-recyclerview,scrollview,Android,Android Recyclerview,Scrollview,我有一个回收视图,其中包含很多帖子。当我滚动recyclerview时,我的框架布局不会滚动。它像导航栏一样固定。 我希望它滚动,就好像它是recyclerview的一部分一样。 以下是我的布局: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.an

我有一个回收视图,其中包含很多帖子。当我滚动recyclerview时,我的框架布局不会滚动。它像导航栏一样固定。 我希望它滚动,就好像它是recyclerview的一部分一样。 以下是我的布局:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    tools:context=".HomePageFragment">

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

        <FrameLayout
            android:id="@+id/status_frame"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"></FrameLayout>

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/recycler"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            ></androidx.recyclerview.widget.RecyclerView>

   </LinearLayout>
</ScrollView>


我的框架布局是状态部分。这是另一个recyclerview本身。滚动帖子时,状态部分不会滚动。

为了让状态部分与recyclerview中的帖子一起滚动,状态部分也应该是recyclerview中的一个项目,因此在这种情况下,您需要具有多个视图类型的
recyclerview

当使用具有多种视图类型的recyclerviews时,只需删除
Framelayout
,这是不必要的

轻微改进

删除不必要的外部
滚动视图,因为默认情况下,recyclerview是可滚动的

编辑


为了使状态部件能够水平滚动,状态部件项布局应该包含一个
recyclerview
,其中还需要为水平recyclerview实现适配器类

要开始使用具有多种视图类型的recyclerview,请参阅



您也可以像在本例中一样使用库。

任何屏幕截图都会有帮助。您所说的状态部分是什么意思?死池圈?是的那些死池圈。它们在帖子的顶部。你想让它们与帖子一起垂直滚动吗?是的,这就是想法。状态部分是另一个水平滚动的回收视图。而post部件则垂直滚动。有可能用你的建议做吗?是的,有可能,更新了答案。如果你满意,请确保投票并接受答案。你可以看看