List of usage examples for android.widget OverScroller fling
public void fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY, int maxY, int overX, int overY)
From source file:com.facebook.react.views.scroll.ReactScrollView.java
private int predictFinalScrollPosition(int velocityY) { // ScrollView can *only* scroll for 250ms when using smoothScrollTo and there's // no way to customize the scroll duration. So, we create a temporary OverScroller // so we can predict where a fling would land and snap to nearby that point. OverScroller scroller = new OverScroller(getContext()); scroller.setFriction(1.0f - mDecelerationRate); // predict where a fling would end up so we can scroll to the nearest snap offset int maximumOffset = getMaxScrollY(); int height = getHeight() - getPaddingBottom() - getPaddingTop(); scroller.fling(getScrollX(), // startX getScrollY(), // startY 0, // velocityX velocityY, // velocityY 0, // minX 0, // maxX 0, // minY maximumOffset, // maxY 0, // overX height / 2 // overY );/*from w ww. ja v a2s . c om*/ return scroller.getFinalY(); }
From source file:com.facebook.react.views.scroll.ReactHorizontalScrollView.java
private int predictFinalScrollPosition(int velocityX) { // ScrollView can *only* scroll for 250ms when using smoothScrollTo and there's // no way to customize the scroll duration. So, we create a temporary OverScroller // so we can predict where a fling would land and snap to nearby that point. OverScroller scroller = new OverScroller(getContext()); scroller.setFriction(1.0f - mDecelerationRate); // predict where a fling would end up so we can scroll to the nearest snap offset int maximumOffset = Math.max(0, computeHorizontalScrollRange() - getWidth()); int width = getWidth() - getPaddingStart() - getPaddingEnd(); scroller.fling(getScrollX(), // startX getScrollY(), // startY velocityX, // velocityX 0, // velocityY 0, // minX maximumOffset, // maxX 0, // minY 0, // maxY width / 2, // overX 0 // overY );//from w ww . j a v a 2s.co m return scroller.getFinalX(); }