Example usage for android.view ViewGroup setScrollY

List of usage examples for android.view ViewGroup setScrollY

Introduction

In this page you can find the example usage for android.view ViewGroup setScrollY.

Prototype

public void setScrollY(int value) 

Source Link

Document

Set the vertical scrolled position of your view.

Usage

From source file:org.chromium.chrome.browser.widget.animation.FocusAnimator.java

/** Scroll the layout so that the focused child is on screen. */
private void requestChildFocus() {
    ViewGroup parent = (ViewGroup) mLayout.getParent();
    if (mLayout.getParent() == null)
        return;/*from   w ww .j a  v a  2  s . com*/

    // Scroll the parent to make the focused child visible.
    if (mFocusedChild != null)
        parent.requestChildFocus(mLayout, mFocusedChild);

    // {@link View#requestChildFocus} fails to account for children changing their height, so
    // the scroll value may be past the actual maximum.
    int viewportHeight = parent.getBottom() - parent.getTop();
    int scrollMax = Math.max(0, mLayout.getMeasuredHeight() - viewportHeight);
    if (parent.getScrollY() > scrollMax)
        parent.setScrollY(scrollMax);
}