Android 嵌套滚动视图中的回收器视图导致使用搜索栏进行过滤时出现延迟
我正在处理这个视图,顶部有一个标题,下面有一个搜索栏,后面是一个嵌套的滚动视图,其中包含一个线性布局,进一步由两个回收器视图组成。布局xml文件可以在下面找到 我面临的问题是,当我通过搜索栏过滤回收器视图中的项目时,在呈现过滤结果时存在明显的延迟。我已经指出了嵌套滚动视图的问题,因为当我去掉它(只有两个回收器视图)时,滞后的问题就完全消失了。当然,随着嵌套滚动视图的消失,我不能再同时滚动两个回收器视图 现在,每个recycler视图有2个适配器,每个适配器都实现了处理过滤逻辑的Filterable接口。此外,我还有一个视图模型类和一个片段类 如果这个问题不能很容易地解决,那么我认为最后的办法是摆脱嵌套的滚动视图,只有一个包含两个列表的回收器视图,并将适配器的数量减少到一个。这将使逻辑变得非常复杂,因此我希望有另一种解决方法 请告诉我你们的想法。欢迎您的任何意见Android 嵌套滚动视图中的回收器视图导致使用搜索栏进行过滤时出现延迟,android,performance,android-recyclerview,android-scrollview,Android,Performance,Android Recyclerview,Android Scrollview,我正在处理这个视图,顶部有一个标题,下面有一个搜索栏,后面是一个嵌套的滚动视图,其中包含一个线性布局,进一步由两个回收器视图组成。布局xml文件可以在下面找到 我面临的问题是,当我通过搜索栏过滤回收器视图中的项目时,在呈现过滤结果时存在明显的延迟。我已经指出了嵌套滚动视图的问题,因为当我去掉它(只有两个回收器视图)时,滞后的问题就完全消失了。当然,随着嵌套滚动视图的消失,我不能再同时滚动两个回收器视图 现在,每个recycler视图有2个适配器,每个适配器都实现了处理过滤逻辑的Filterabl
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/invite_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<include
android:id="@+id/header"
layout="@layout/component_bars_navigation_nav_sub"
android:layout_width="match_parent"
android:layout_height="@dimen/XXXL"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<include
android:id="@+id/search_bar"
layout="@layout/layout_component_bars_row_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/add_friend_header" />
<androidx.core.widget.NestedScrollView
android:id="@+id/invite_list_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:overScrollMode="always"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/search_bar">
<LinearLayout
android:id="@+id/invite_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/XXXXL"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="parent">
<include
android:id="@+id/label_1"
layout="@layout/layout_component_bars_row_label"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:paddingBottom="@dimen/S"
android:visibility="visible"
tools:itemCount="3"
tools:layout_editor_absoluteX="-50dp"
tools:listitem="@layout/components_1_item"
tools:visibility="visible" />
<include
android:id="@+id/label_2"
layout="@layout/layout_component_bars_row_label"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
android:paddingBottom="@dimen/S"
android:visibility="visible"
tools:itemCount="2"
tools:layout_editor_absoluteX="-50dp"
tools:listitem="@layout/components_2_item"
tools:visibility="visible" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
最后,我找到了解决这个问题的解决方案。我没有使用多个回收器视图,而是将它们组合成一个具有多种视图类型的视图 如果人们仍然感到困惑,以下链接可能会有所帮助,因为他们帮助了我:)
为什么不只使用一个具有多种视图类型的recyclerview?这样,您也不需要nestedscrollview