Back to project page PECSMobile.
The source code is released under:
GNU General Public License
If you think the Android project PECSMobile 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.jjoseba.pecsmobile.ui; //from w ww . java 2 s . com import android.content.Context; import android.support.v4.view.ViewPager; import android.util.AttributeSet; import android.view.animation.DecelerateInterpolator; import android.widget.Scroller; import java.lang.reflect.Field; /** * Created by Joseba on 28/12/2014. */ public class SmoothScrollerViewPager extends EnableableViewPager { public SmoothScrollerViewPager(Context context, AttributeSet attrs) { super(context, attrs); setMyScroller(); } private void setMyScroller() { try { Class<?> viewpager = ViewPager.class; Field scroller = viewpager.getDeclaredField("mScroller"); scroller.setAccessible(true); scroller.set(this, new SmoothScroller(getContext())); } catch (Exception e) { e.printStackTrace(); } } public class SmoothScroller extends Scroller { public SmoothScroller(Context context) { super(context, new DecelerateInterpolator()); } @Override public void startScroll(int startX, int startY, int dx, int dy, int duration) { super.startScroll(startX, startY, dx, dy, 700); } } }