Android Open Source - Coloring-book Fixed Speed View Pager

From Project

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.

Java Source Code

// ww w  .  ja  v  a 2 s .c om
import java.lang.reflect.Field;

import android.content.Context;
import android.util.AttributeSet;
import android.view.animation.Interpolator;

public class FixedSpeedViewPager extends ViewPager {

    public FixedSpeedViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);

    private FixedSpeedScroller mScroller = null;

     * Override the Scroller instance with our own class so we can change the
     * duration

    public void setCurrentItem(int item, boolean smoothScroll) {
        super.setCurrentItem(item, smoothScroll);

    private void postInitViewPager() {
        try {
            Class<?> viewpager = ViewPager.class;
            Field scroller = viewpager.getDeclaredField("mScroller");
            Field interpolator = viewpager.getDeclaredField("sInterpolator");

            mScroller = new FixedSpeedScroller(getContext(),
                    (Interpolator) interpolator.get(null));
            scroller.set(this, mScroller);
        } catch (Exception e) {


Java Source Code List