具有反向布局的 RecyclerView 上的 Android SwipeRefreshLayout

标签 android android-recyclerview swiperefreshlayout

我在 Android 的 SwipeRefreshLayout 中使用 RecyclerView。

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/mySwipeRefresh"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">

    <RecyclerView
        android:id="@+id/myRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

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

在这个 RecyclerView 中,我使用了一个 LinearLayoutManager,它具有反向布局和从末尾开始的堆栈:

LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);

myRecyclerView.setLayoutManager(layoutManager);

因此,滚动内容从底部开始,适配器从底部到顶部添加项目。

使用此配置,我想在 RecyclerView 位于底部并且用户尝试向下滚动时显示 SwipeRefreshLayout。相反,结果是 SwipeRefreshLayout 具有标准行为,当用户滚动到顶部且 RecyclerView 位于顶部时,从上到下显示动画。

我没有找到执行此操作的 API,我该如何解决这个问题?

谢谢

最佳答案

我决定使用这个库,因为 SwipeRefreshLayout 不支持反向布局

Refresh layout bottom

关于具有反向布局的 RecyclerView 上的 Android SwipeRefreshLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33068361/

相关文章:

android - ThemeRoller 不适用于设备

android - 生成签名 APK 成功,但谷歌播放说它没有签名

android - 服务不停

android - notifyDataSetChanged() 不刷新适配器

android - Admob 原生高级广告在 recyclerview 中重复

android - SwipeRefreshLayout 阻止水平滚动的 RecyclerView

android - SwipeRefreshLayout 刷新动画不会停止

android - 自定义 ArrayAdapter getView 未被调用——为什么不呢?

kotlin - 如何使用 Androidx 在 Kotlin 中获取 DialogFragment 的 FragmentManager?

android - SwipeRefreshLayout 触摸 View 末尾时刷新