向下滑动以刷新Material Design

Hug*_*eta 3 android pull-to-refresh material-design android-5.0-lollipop android-recyclerview

我一直在寻找新材料设计的实施,以便在RecyclerViews上刷新,从ActionBar下载加载圈,就像新的Gmail应用程序一样.我还没有找到类似的东西,只有一些SwipeRefreshLayout + RecyclerView示例.有谁知道如何做到这一点?

teh*_*nsi 20

您可以使用appcombat支持库中提供的SwipeToRefresh视图:

compile 'com.android.support:appcompat-v7:21.0.0'
Run Code Online (Sandbox Code Playgroud)

以下是与RecyclerView结合使用的方法

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe_refresh_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:clipToPadding="false"
        android:layout_height="match_parent"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_horizontal_margin"
        android:paddingBottom="@dimen/activity_vertical_margin" />

</android.support.v4.widget.SwipeRefreshLayout>
Run Code Online (Sandbox Code Playgroud)

希望我能帮忙!