Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- **
- * <pre>
- * author : jarylan
- * e-mail : jarylan@foxmail.com
- * time : 2017/04/24
- * desc : 调节 ViewPager 滑动速度;
- * version: 1.0
- * </pre>
- *
- * 使用示例 :
- Field mScroller = ViewPager.class.getDeclaredField("mScroller");
- mScroller.setAccessible(true);
- FixedSpeedScroller scroller = new FixedSpeedScroller( viewpager.getContext() );
- mScroller.set( viewpager, scroller);
- */
- public class FixedSpeedScroller extends Scroller {
- public final static int SPEED_FAST = 0;
- public final static int SPEED_SLOW = 500;
- private int mDuration = 0;
- public FixedSpeedScroller(Context context,int duration) {
- super(context);
- this.mDuration = duration;
- }
- public FixedSpeedScroller(Context context, Interpolator interpolator) {
- super(context, interpolator);
- }
- @SuppressLint("NewApi")
- public FixedSpeedScroller(Context context, Interpolator interpolator,
- boolean flywheel) {
- super(context, interpolator, flywheel);
- // TODO Auto-generated constructor stub
- }
- @Override
- public void startScroll(int startX, int startY, int dx, int dy, int duration) {
- super.startScroll(startX, startY, dx, dy, mDuration);
- }
- @Override
- public void startScroll(int startX, int startY, int dx, int dy) {
- super.startScroll(startX, startY, dx, dy, mDuration);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement