Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. **
  2. * <pre>
  3. * author : jarylan
  4. * e-mail : jarylan@foxmail.com
  5. * time : 2017/04/24
  6. * desc : 调节 ViewPager 滑动速度;
  7. * version: 1.0
  8. * </pre>
  9. *
  10. * 使用示例 :
  11. Field mScroller = ViewPager.class.getDeclaredField("mScroller");
  12. mScroller.setAccessible(true);
  13. FixedSpeedScroller scroller = new FixedSpeedScroller( viewpager.getContext() );
  14. mScroller.set( viewpager, scroller);
  15. */
  16. public class FixedSpeedScroller extends Scroller {
  17.  
  18. public final static int SPEED_FAST = 0;
  19. public final static int SPEED_SLOW = 500;
  20. private int mDuration = 0;
  21.  
  22. public FixedSpeedScroller(Context context,int duration) {
  23. super(context);
  24. this.mDuration = duration;
  25. }
  26.  
  27. public FixedSpeedScroller(Context context, Interpolator interpolator) {
  28. super(context, interpolator);
  29. }
  30.  
  31. @SuppressLint("NewApi")
  32. public FixedSpeedScroller(Context context, Interpolator interpolator,
  33. boolean flywheel) {
  34. super(context, interpolator, flywheel);
  35. // TODO Auto-generated constructor stub
  36. }
  37.  
  38. @Override
  39. public void startScroll(int startX, int startY, int dx, int dy, int duration) {
  40. super.startScroll(startX, startY, dx, dy, mDuration);
  41. }
  42.  
  43. @Override
  44. public void startScroll(int startX, int startY, int dx, int dy) {
  45. super.startScroll(startX, startY, dx, dy, mDuration);
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement