Example usage for android.view ViewGroup getScrollY

List of usage examples for android.view ViewGroup getScrollY

Introduction

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

Prototype

public final int getScrollY() 

Source Link

Document

Return the scrolled top position of this view.

Usage

From source file:com.ranger.xyg.library.tkrefreshlayout.utils.ScrollingUtil.java

public static boolean isViewGroupToBottom(ViewGroup viewGroup) {
    View subChildView = viewGroup.getChildAt(0);
    return (subChildView != null
            && subChildView.getMeasuredHeight() <= viewGroup.getScrollY() + viewGroup.getHeight());
}

From source file:android.support.transition.ChangeTransform.java

private void captureValues(TransitionValues transitionValues) {
    View view = transitionValues.view;
    if (view.getVisibility() == View.GONE) {
        return;//  w ww. java2  s .  co m
    }
    transitionValues.values.put(PROPNAME_PARENT, view.getParent());
    Transforms transforms = new Transforms(view);
    transitionValues.values.put(PROPNAME_TRANSFORMS, transforms);
    Matrix matrix = view.getMatrix();
    if (matrix == null || matrix.isIdentity()) {
        matrix = null;
    } else {
        matrix = new Matrix(matrix);
    }
    transitionValues.values.put(PROPNAME_MATRIX, matrix);
    if (mReparent) {
        Matrix parentMatrix = new Matrix();
        ViewGroup parent = (ViewGroup) view.getParent();
        ViewUtils.transformMatrixToGlobal(parent, parentMatrix);
        parentMatrix.preTranslate(-parent.getScrollX(), -parent.getScrollY());
        transitionValues.values.put(PROPNAME_PARENT_MATRIX, parentMatrix);
        transitionValues.values.put(PROPNAME_INTERMEDIATE_MATRIX, view.getTag(R.id.transition_transform));
        transitionValues.values.put(PROPNAME_INTERMEDIATE_PARENT_MATRIX, view.getTag(R.id.parent_matrix));
    }
}

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  w w .jav a  2 s  .  c o  m

    // 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);
}

From source file:com.android.argb.edhlc.Utils.java

public static void makeViewVisible(View view) {
    int viewTop = view.getTop();
    int viewBottom = view.getBottom();

    for (;;) {//from   ww  w . j a v  a2 s .  c o m
        ViewParent viewParent = view.getParent();
        if (viewParent == null || !(viewParent instanceof ViewGroup))
            break;

        ViewGroup viewGroupParent = (ViewGroup) viewParent;
        if (viewGroupParent instanceof NestedScrollView) {

            NestedScrollView nestedScrollView = (NestedScrollView) viewGroupParent;
            int height = nestedScrollView.getHeight();
            int screenTop = nestedScrollView.getScrollY();
            int screenBottom = screenTop + height;
            int fadingEdge = nestedScrollView.getVerticalFadingEdgeLength();

            // leave room for top fading edge as long as rect isn't at very top
            if (viewTop > 0)
                screenTop += fadingEdge;

            // leave room for bottom fading edge as long as rect isn't at very bottom
            if (viewBottom < nestedScrollView.getChildAt(0).getHeight())
                screenBottom -= fadingEdge;

            int scrollYDelta = 0;

            if (viewBottom > screenBottom && viewTop > screenTop) {
                // need to move down to get it in view: move down just enough so
                // that the entire rectangle is in view (or at least the first
                // screen size chunk).

                if (viewBottom - viewTop > height) // just enough to get screen size chunk on
                    scrollYDelta += (viewTop - screenTop);
                else // get entire rect at bottom of screen
                    scrollYDelta += (viewBottom - screenBottom);

                // make sure we aren't scrolling beyond the end of our content
                int bottom = nestedScrollView.getChildAt(0).getBottom();
                int distanceToBottom = bottom - screenBottom;
                scrollYDelta = Math.min(scrollYDelta, distanceToBottom);

            } else if (viewTop < screenTop && viewBottom < screenBottom) {
                // need to move up to get it in view: move up just enough so that
                // entire rectangle is in view (or at least the first screen
                // size chunk of it).

                if (viewBottom - viewTop > height) // screen size chunk
                    scrollYDelta -= (screenBottom - viewBottom);
                else // entire rect at top
                    scrollYDelta -= (screenTop - viewTop);

                // make sure we aren't scrolling any further than the top our content
                scrollYDelta = Math.max(scrollYDelta, -nestedScrollView.getScrollY());
            }
            nestedScrollView.smoothScrollBy(0, scrollYDelta);
            break;
        }
        // Transform coordinates to parent:
        int dy = viewGroupParent.getTop() - viewGroupParent.getScrollY();
        viewTop += dy;
        viewBottom += dy;

        view = viewGroupParent;
    }
}