setColorSchemeResources sets the colors of the SwipeToRefreshLayout indicator
setOnRefreshListener sets what to do when layout is swiped
app:layout_behavior="@string/appbar_scrolling_view_behavior" if you have a Toolbar with your layout, add this with the scrollFlags in Toolbar and the Toolbar will slide up while scrolling down and slide in again while scrolling up.
How to add Swipe-to-Refresh To your app
Make sure the following dependency is added to your app's build.gradle file under dependencies:
Then add the SwipeRefreshLayout in your layout:
Finally implement the SwipeRefreshLayout.OnRefreshListener listener.
Swipe To Refresh with RecyclerView
To add a Swipe To Refresh layout with a RecyclerView add the following to your Activity/Fragment layout file:
In your Activity/Fragment add the following to initialize the SwipeToRefreshLayout:
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0