how to set slide speed?
jae1jeong opened this issue · 1 comments
jae1jeong commented
How to set slide speed?
is there any method to set slide speed?
vidarrrr commented
public class OwnScroller extends Scroller {
private int durationScrollMs;
private final int MS = 1000;
public OScroller(Context context, int secondScrollDuration) {
super(context);
this.durationScrollMs = secondScrollDuration * MS;
}
@Override
public void startScroll(int startX, int startY, int dx, int dy, int duration) {
super.startScroll(startX, startY, dx, dy, this.durationScrollMs);
}
}
Try to create a custom scroller class and override the startScroll function with your own duration.
LoopingViewPager loopingViewPager = findViewById(R.id.viewpager);
private final int durationSec = 5;
try{
Class<?> viewPager = ViewPager.class;
Field scroller = viewPager.getDeclaredField("mScroller");
scroller.setAccessible(true);
scroller.set(loopingViewPager,new OwnScroller(context,durationSec));
}catch (Exception e){
e.printStackTrace();
}
Try to call with reflection and set your custom scroll class.