How to adjust the swipe down distance in SwipeRefreshLayout?

Anirudh picture Anirudh · Apr 4, 2014 · Viewed 21.1k times · Source

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  

}

Answer

Han He picture Han He · Oct 27, 2014

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.