SwipeRefreshLayout - swipe down to refresh but not move the view pull down

前端 未结 5 1876
深忆病人
深忆病人 2020-12-08 12:29

Is it possible ?? as a Title said

swipe down to refresh Layout but stick the Layout not move it down along swipe gusture

Thank you - I\'m us

5条回答
  •  误落风尘
    2020-12-08 12:42

    After my trial and error, I found one solution from

    http://www.dailydevbook.de/android-swiperefreshlayout-without-overscroll/

    For people who can implement SwipeRefreshLayout, in order to achieve it


    STEP 1: DOWNLOAD android-support v4 (Open Source) from github

    • android-support v4 - Download Link

    STEP 2: COPY following java class to your project src

    • SwipeRefreshLayout
    • SwipeProgressBar
    • BakedBezierInterpolator

    note1- (Refactor SwipeRefreshLayout to mySwipeRefreshLayout to prevent confusing with original) note2- (Fix these classes and use the source from each other instead of v4)

    STEP 3: UPDATE CODE use

    • mySwipeRefreshLayout instead of
    • SwipeRefreshLayout

    STEP 4: UPDATE LAYOUT use

    • com.yourpackage.mySwipeRefreshLaout instead of
    • android.support.v4.widget.SwipeRefreshLayout

    STEP 5: In your mySwipeRefreshLayout.java, find and change to a following code

    private  void  updateContentOffsetTop ( int  targetTop) {
            final  int  currentTop = mTarget.getTop ();
            if  (targetTop> mDistanceToTriggerSync) {
                targetTop = ( int ) mDistanceToTriggerSync;
            } else  if  (targetTop < 0 ) {
                targetTop = 0 ;
            }
            // SetTargetOffsetTopAndBottom (targetTop - currentTop);
            setTargetOffsetTopAndBottom ( 0 ); // MOD: Prevent Scroll Down Animation
        }
    

提交回复
热议问题