Back to project page Coloring-book.
The source code is released under:
Apache License
If you think the Android project Coloring-book listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.kidsgames.menu; // ww w . ja v a 2 s .c om import java.lang.reflect.Field; import android.content.Context; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.animation.Interpolator; public class FixedSpeedViewPager extends ViewPager { public FixedSpeedViewPager(Context context, AttributeSet attrs) { super(context, attrs); postInitViewPager(); } private FixedSpeedScroller mScroller = null; /** * Override the Scroller instance with our own class so we can change the * duration */ @Override public void setCurrentItem(int item, boolean smoothScroll) { super.setCurrentItem(item, smoothScroll); } private void postInitViewPager() { try { Class<?> viewpager = ViewPager.class; Field scroller = viewpager.getDeclaredField("mScroller"); scroller.setAccessible(true); Field interpolator = viewpager.getDeclaredField("sInterpolator"); interpolator.setAccessible(true); mScroller = new FixedSpeedScroller(getContext(), (Interpolator) interpolator.get(null)); scroller.set(this, mScroller); } catch (Exception e) { e.printStackTrace(); } } }