Example usage for android.widget HorizontalScrollView getScrollY

List of usage examples for android.widget HorizontalScrollView getScrollY

Introduction

In this page you can find the example usage for android.widget HorizontalScrollView getScrollY.

Prototype

public final int getScrollY() 

Source Link

Document

Return the scrolled top position of this view.

Usage

From source file:com.facebook.react.views.scroll.ReactHorizontalScrollContainerView.java

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    if (mLayoutDirection == LAYOUT_DIRECTION_RTL) {
        // When the layout direction is RTL, we expect Yoga to give us a layout
        // that extends off the screen to the left so we re-center it with left=0
        int newLeft = 0;
        int width = right - left;
        int newRight = newLeft + width;
        setLeft(newLeft);//from w ww . j  a va  2 s.co m
        setRight(newRight);

        // Call with the present values in order to re-layout if necessary
        HorizontalScrollView parent = (HorizontalScrollView) getParent();
        // Fix the ScrollX position when using RTL language
        int offsetX = parent.getScrollX() + getWidth() - mCurrentWidth;
        parent.scrollTo(offsetX, parent.getScrollY());
    }
    mCurrentWidth = getWidth();
}