3

I've been looking around for the implementation of the new material design swipe down to refresh on RecyclerViews with the loading circle coming down from the ActionBar, like the new Gmail app. I haven't found anything similar yet, only some SwipeRefreshLayout+RecyclerView examples. Does anyone know how to do this?

hichris123
  • 10,145
  • 15
  • 56
  • 70
Hugo M. Zuleta
  • 572
  • 1
  • 13
  • 27

1 Answers1

20

You can use the SwipeToRefresh view provided in the appcombat support library:

compile 'com.android.support:appcompat-v7:21.0.0'

Here's how you can use it in combination with 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>

Hope I could help!

teh.fonsi
  • 3,040
  • 2
  • 27
  • 22