添加 SwipeRefreshLayout 后,NestedScrollView 不再工作

问题描述

我注意到我的应用程序中有一个奇怪的行为。 我的滚动视图包含两个元素。

  1. 一个搜索视图
  2. 一个 RecyclerView

那些由 LinearLayout 包装。 现在我想添加一个 SwipeRefreshLayout 来刷新 RecyclerView 中包含的数据。 一旦我这样做,ScrollView 就会忽略 SearchView,只滚动 RecyclerView。

这里是 XML:

<androidx.core.widget.nestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">



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


            <SearchView
                android:id="@+id/search_bar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:iconifiedByDefault="false"
                android:layout_marginTop="45dp"
                android:queryHint="Search Here" />

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

            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/listRV"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="gone" />

            </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

        </LinearLayout>

</androidx.core.widget.nestedScrollView>

它应该同时滚动 SearchView 和 RecyclerView。 为什么它在我添加 SwipeRefreshLayout 后立即停止工作,我该如何解决

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)