我在 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 不支持反向布局
关于具有反向布局的 RecyclerView 上的 Android SwipeRefreshLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33068361/