简体   繁体   English

RecyclerView 上的 Android SwipeRefreshLayout 反向布局

[英]Android SwipeRefreshLayout on RecyclerView with reverse layout

I'm using a RecyclerView inside a SwipeRefreshLayout in Android.我在 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>

In this RecyclerView i'm using a LinearLayoutManager with reverse layout and stack from end:在这个 RecyclerView 中,我使用的是带有反向布局和堆栈的 LinearLayoutManager:

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

myRecyclerView.setLayoutManager(layoutManager);

So, the scrolling content starts from bottom and items are added by adapter from bottom to top.因此,滚动内容从底部开始,项目由适配器从下到上添加。

With this configuration, i'd like to show SwipeRefreshLayout when RecyclerView is at the bottom and user try scrolling more down.使用此配置,当 RecyclerView 位于底部并且用户尝试向下滚动时,我想显示 SwipeRefreshLayout。 Instead, the results is that SwipeRefreshLayout has the standard behavior and is shown from top to bottom animation when user scrolls to top and RecyclerView is at the top.相反,结果是 SwipeRefreshLayout 具有标准行为,并且当用户滚动到顶部并且 RecyclerView 位于顶部时从上到下显示动画。

I didn't find apis to do this, how can i solve this issue?我没有找到 apis 来做到这一点,我该如何解决这个问题?

Thanks谢谢

I resolved using this library since SwipeRefreshLayout doesn't support reverse layout我解决了使用这个库,因为 SwipeRefreshLayout 不支持反向布局

Refresh layout bottom 刷新布局底部

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM