滚动 recyclerview 时,滚动视图内的视图不滚动
View inside scrollview doesn't scroll while scrolling recyclerview
我有一个回收站视图,其中包含很多帖子。当我滚动 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>
我尝试使用 nestedScrollView,但它添加了额外的空帖子。不知道为什么。
我的frameLayout是状态部分。这是另一个 recyclerview itself.while 滚动状态部分不滚动的帖子。
为了让状态部分在回收站视图中与帖子一起滚动,状态部分也应该是回收站视图中的一个项目,所以在这种情况下你需要 recyclerview with multiple view types
。 Plase read: How to create recyclerview with multiple view types.
只需删除 Framelayout
它不是必需的,当使用具有多种视图类型的 recyclerviews 时。
小改进
移除不必要的外部 scrollview
,因为默认情况下 recyclerview 是可滚动的。
编辑:
为了让状态部分可以水平滚动,状态部分项目布局应该包含一个 recyclerview
其中 记得为水平回收视图实现适配器 class。
要开始使用具有多种视图类型的 recyclerview,您可以查看 this tutorial。
在这种情况下,您也可以使用像 Epoxy 这样的库。
我有一个回收站视图,其中包含很多帖子。当我滚动 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>
我尝试使用 nestedScrollView,但它添加了额外的空帖子。不知道为什么。
我的frameLayout是状态部分。这是另一个 recyclerview itself.while 滚动状态部分不滚动的帖子。
为了让状态部分在回收站视图中与帖子一起滚动,状态部分也应该是回收站视图中的一个项目,所以在这种情况下你需要 recyclerview with multiple view types
。 Plase read: How to create recyclerview with multiple view types.
只需删除 Framelayout
它不是必需的,当使用具有多种视图类型的 recyclerviews 时。
小改进
移除不必要的外部 scrollview
,因为默认情况下 recyclerview 是可滚动的。
编辑:
为了让状态部分可以水平滚动,状态部分项目布局应该包含一个 recyclerview
其中
要开始使用具有多种视图类型的 recyclerview,您可以查看 this tutorial。
在这种情况下,您也可以使用像 Epoxy 这样的库。