How to adjust the swipe down distance in SwipeRefreshLayout?

后端 未结 4 2010
没有蜡笔的小新
没有蜡笔的小新 2020-12-12 16:55

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 h

4条回答
  •  春和景丽
    2020-12-12 17:26

    Currently there isn't a public method, or even an internal one for that matter, that can be used to adjust the trigger distance. But you can copy over the three classes from the support library into your project, then modify SwipeRefreshLayout to your liking.

    Here are the classes you'll need to copy over:

    • BakedBezierInterpolator
    • SwipeProgressBar
    • SwipeRefreshLayout

    The tigger distance is calculated using the constants:

     private static final float MAX_SWIPE_DISTANCE_FACTOR = .6f;
     private static final int REFRESH_TRIGGER_DISTANCE = 120;
    

    In your layout change to and make sure you change your imports, if you need to.

提交回复
热议问题