Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to adjust the swipe down distance in SwipeRefreshLayout?

I implemented SwipeRefreshLayout in my app. I need to change the height which has to be scrolled down to call onRefresh() method. Which method should I use to add a custom height ?

Implementation of SwipeRefreshLayout

private SwipeRefreshLayout swipeLayout; 

In oncreate

swipeLayout   = (SwipeRefreshLayout)view.findViewById(R.id.swipe_container); swipeLayout.setOnRefreshListener(this);         swipeLayout.setColorScheme(android.R.color.holo_blue_dark,                  android.R.color.holo_green_dark,                  android.R.color.holo_purple,                  android.R.color.holo_orange_dark);            swipeLayout.setSoundEffectsEnabled(true); 

Implementing an AsyncTask in onrefresh method

   @Override public void onRefresh()  {     // Asynctask to perform some task    } 
like image 391
Anirudh Avatar asked Apr 04 '14 07:04

Anirudh


People also ask

What is Swipe refresh layout in Android studio?

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.

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.


1 Answers

The reversion 21 of v4 support library has provided a API to set the distance.

public void setDistanceToTriggerSync (int distance) 

Check the document here.

One more thing, the rev. 21 changed the behaviour of progress bar, it's now a circle image. Have no idea how to get the old way back.

like image 146
Han He Avatar answered Sep 20 '22 20:09

Han He