Created
September 15, 2017 12:59
-
-
Save ponnamkarthik/6b2e358ffd66ec84673ce472e177fdcc to your computer and use it in GitHub Desktop.
ViewPage Scrolling Duration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
Field mScroller = null; | |
mScroller = ViewPager.class.getDeclaredField("mScroller"); | |
mScroller.setAccessible(true); | |
ViewPagerScroller scroller = new ViewPagerScroller(viewPager.getContext()); | |
mScroller.set(viewPager, scroller); | |
} catch (Exception e) { | |
Log.e("GHM", "error ", e); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.rcc.newdesign.utils; | |
import android.content.Context; | |
import android.view.animation.Interpolator; | |
import android.widget.Scroller; | |
/** | |
* Created by ponna on 15-09-2017. | |
*/ | |
public class ViewPagerScroller extends Scroller { | |
private int mScrollDuration = 1000; | |
public ViewPagerScroller(Context context) { | |
super(context); | |
} | |
public ViewPagerScroller(Context context, Interpolator interpolator) { | |
super(context, interpolator); | |
} | |
public ViewPagerScroller(Context context, Interpolator interpolator, boolean flywheel) { | |
super(context, interpolator, flywheel); | |
} | |
@Override | |
public void startScroll(int startX, int startY, int dx, int dy, int duration) { | |
super.startScroll(startX, startY, dx, dy, mScrollDuration); | |
} | |
@Override | |
public void startScroll(int startX, int startY, int dx, int dy) { | |
super.startScroll(startX, startY, dx, dy, mScrollDuration); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment