Example usage for android.widget OverScroller getFinalY

List of usage examples for android.widget OverScroller getFinalY

Introduction

In this page you can find the example usage for android.widget OverScroller getFinalY.

Prototype

public final int getFinalY() 

Source Link

Document

Returns where the scroll will end.

Usage

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
    );/* w w  w. jav a  2 s .c o  m*/
    return scroller.getFinalY();
}