Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement "Swipe down to refresh" like in new GMail app

Google release the new Gmail app with an alternate way to handle pull down to refresh.

Instead of showing the started hidden row that is pulled down. Gmail displays an animated message overtop of the action bar.

The message includes an animated horizontal line.

Is this a standard feature of the Android SDK? I can't find anything in the action bar API that would do this.

enter image description here

like image 503
Reactgular Avatar asked Jun 10 '13 17:06

Reactgular


People also ask

How do I use swipe refresh layout?

To add the swipe to refresh widget to an existing app, add SwipeRefreshLayout as the parent of a single ListView or GridView . Remember that SwipeRefreshLayout only supports a single ListView or GridView child. You can also use the SwipeRefreshLayout widget with a ListFragment .

How do I stop swipe refresh layout?

To disable the gesture and progress animation, call setEnabled(false) on the view. This layout should be made the parent of the view that will be refreshed as a result of the gesture and can only support one direct child.

What is SwipeRefreshLayout?

Android SwipeRefreshLayout is a ViewGroup that can hold only one scrollable child. It can be either a ScrollView, ListView or RecyclerView. The basic need for a SwipeRefreshLayout is to allow the users to refresh the screen manually.

Why is the Gmail widget blue?

According to a helpful volunteer support person, one of the "Labs" you can enable in Gmail is what's causing some people to see a blue icon. Labs are experimental custom features that you can tweak to change the way your mail looks or works. The one that's causing the blue icon is the "Unread message icon" Lab.


2 Answers

Google has released support for this directly in the SDK. I am not sure of what version you need to support (that may be an issue).

Check out the official SDK feature info here: http://developer.android.com/reference/android/support/v4/widget/SwipeRefreshLayout.html

If you are able to use the SDK one, you will be better off, even Chris Banes wrote a post, suggesting the same.

like image 153
Booger Avatar answered Oct 04 '22 20:10

Booger


Chris Banes' ActionBar-PullToRefresh library on GitHub probably offers pull-to-refresh functionality closest to GMail app.

See also: Juhani Lehtimäki's analysis of GMail pull-to-refresh.

like image 20
laalto Avatar answered Oct 04 '22 19:10

laalto