Example usage for android.view View getBottom

List of usage examples for android.view View getBottom

Introduction

In this page you can find the example usage for android.view View getBottom.

Prototype

@ViewDebug.CapturedViewProperty
public final int getBottom() 

Source Link

Document

Bottom position of this view relative to its parent.

Usage

From source file:com.apptentive.android.sdk.view.ApptentiveNestedScrollView.java

/**
 * <p>Handles scrolling in response to a "page up/down" shortcut press. This
 * method will scroll the view by one page up or down and give the focus
 * to the topmost/bottommost component in the new visible area. If no
 * component is a good candidate for focus, this scrollview reclaims the
 * focus.</p>/*from   www  .j a  v  a2 s  .  co m*/
 *
 * @param direction the scroll direction: {@link android.view.View#FOCUS_UP}
 *                  to go one page up or
 *                  {@link android.view.View#FOCUS_DOWN} to go one page down
 * @return true if the key event is consumed by this method, false otherwise
 */
public boolean pageScroll(int direction) {
    boolean down = direction == View.FOCUS_DOWN;
    int height = getHeight();

    if (down) {
        mTempRect.top = getScrollY() + height;
        int count = getChildCount();
        if (count > 0) {
            View view = getChildAt(count - 1);
            if (mTempRect.top + height > view.getBottom()) {
                mTempRect.top = view.getBottom() - height;
            }
        }
    } else {
        mTempRect.top = getScrollY() - height;
        if (mTempRect.top < 0) {
            mTempRect.top = 0;
        }
    }
    mTempRect.bottom = mTempRect.top + height;

    return scrollAndFocus(direction, mTempRect.top, mTempRect.bottom);
}

From source file:com.aidy.bottomdrawerlayout.BottomDrawerLayout.java

@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    Log.i(TAG, "drawChild()");
    final int width = getWidth();
    final boolean drawingContent = isContentView(child);
    int clipTop = 0;
    int clipBottom = getHeight();

    final int restoreCount = canvas.save();
    if (drawingContent) {
        final int childCount = getChildCount();
        for (int i = 0; i < childCount; i++) {
            final View v = getChildAt(i);
            if (v == child || v.getVisibility() != VISIBLE || !hasOpaqueBackground(v) || !isDrawerView(v)
                    || v.getWidth() < width) {
                Log.i(TAG, "drawChild() -- 0");
                continue;
            }// ww w.ja va 2  s . co  m
            if (checkDrawerViewAbsoluteGravity(v, Gravity.TOP)) {
                final int vbottom = v.getBottom();
                if (vbottom > clipTop)
                    clipTop = vbottom;
            } else {
                final int vtop = v.getTop();
                if (vtop < clipBottom) {
                    clipBottom = vtop;
                }
            }
        }
        canvas.clipRect(0, clipTop, getWidth(), clipBottom);
    }
    final boolean result = super.drawChild(canvas, child, drawingTime);
    canvas.restoreToCount(restoreCount);

    if (mScrimOpacity > 0 && drawingContent) {
        Log.i(TAG, "drawChild() -- drawingContent");
        final int baseAlpha = (mScrimColor & 0xff000000) >>> 24;
        final int imag = (int) (baseAlpha * mScrimOpacity);
        final int color = imag << 24 | (mScrimColor & 0xffffff);
        mScrimPaint.setColor(color);
        canvas.drawRect(0, clipTop, getWidth(), clipBottom, mScrimPaint);
    } else if (mShadowBottom != null && checkDrawerViewAbsoluteGravity(child, Gravity.BOTTOM)) {
        Log.i(TAG, "drawChild() -- Gravity.BOTTOM");
        final int shadowHeight = mShadowBottom.getIntrinsicWidth();
        final int childTop = child.getTop();
        final int showing = getHeight() - childTop;
        final int drawerPeekDistance = mBottomDragger.getEdgeSize();
        final float alpha = Math.max(0, Math.min((float) showing / drawerPeekDistance, 1.f));
        mShadowBottom.setBounds(child.getLeft(), childTop - shadowHeight, child.getRight(), childTop);
        mShadowBottom.setAlpha((int) (0xff * alpha));
        mShadowBottom.draw(canvas);
    }
    return result;
}

From source file:com.miuhouse.yourcompany.student.view.widget.LazyViewPager.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v// w w w  .  j a v  a  2s .  co  m
 *            View to test for horizontal scrollability
 * @param checkV
 *            Whether the view v passed should itself be checked for
 *            scrollability (true), or just its children (false).
 * @param dx
 *            Delta scrolled in pixels
 * @param x
 *            X coordinate of the active touch point
 * @param y
 *            Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 */
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance
        // first.
        for (int i = count - 1; i >= 0; i--) {
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV && ViewCompat.canScrollHorizontally(v, -dx);
}

From source file:com.example.zhaozhu.practisecustomview.customviewgroup.HSlidingPaneLayout.java

@Override
public void draw(final Canvas c) {
    super.draw(c);

    final View shadowView = this.getChildCount() > 1 ? this.getChildAt(1) : null;
    if ((shadowView == null) || (this.mShadowDrawable == null)) {
        // No need to draw a shadow if we don't have one.
        return;//from  w w  w.  ja v a  2  s  .c  om
    }

    final int shadowWidth = this.mShadowDrawable.getIntrinsicWidth();
    final int right = shadowView.getLeft();
    final int top = shadowView.getTop();
    final int bottom = shadowView.getBottom();
    final int left = right - shadowWidth;
    this.mShadowDrawable.setBounds(left, top, right, bottom);
    this.mShadowDrawable.draw(c);
}

From source file:com.abewy.android.apps.klyph.messenger.widget.SlidingPaneLayout.java

void updateObscuredViewsVisibility(View panel) {
    final int leftBound = getPaddingLeft();
    final int rightBound = getWidth() - getPaddingRight();
    final int topBound = getPaddingTop();
    final int bottomBound = getHeight() - getPaddingBottom();
    final int left;
    final int right;
    final int top;
    final int bottom;
    if (panel != null && hasOpaqueBackground(panel)) {
        left = panel.getLeft();/*from   w  w  w  .  ja  va2 s .  co m*/
        right = panel.getRight();
        top = panel.getTop();
        bottom = panel.getBottom();
    } else {
        left = right = top = bottom = 0;
    }

    for (int i = 0, childCount = getChildCount(); i < childCount; i++) {
        final View child = getChildAt(i);

        if (child == panel) {
            // There are still more children above the panel but they won't be affected.
            break;
        }

        final int clampedChildLeft = Math.max(leftBound, child.getLeft());
        final int clampedChildTop = Math.max(topBound, child.getTop());
        final int clampedChildRight = Math.min(rightBound, child.getRight());
        final int clampedChildBottom = Math.min(bottomBound, child.getBottom());
        final int vis;
        if (clampedChildLeft >= left && clampedChildTop >= top && clampedChildRight <= right
                && clampedChildBottom <= bottom) {
            vis = INVISIBLE;
        } else {
            vis = VISIBLE;
        }
        child.setVisibility(vis);
    }
}

From source file:cn.emagsoftware.ui.BugFixedSlidingPaneLayout.java

void updateObscuredViewsVisibility(View panel) {
    final int leftBound = getPaddingLeft();
    final int rightBound = getWidth() - getPaddingRight();
    final int topBound = getPaddingTop();
    final int bottomBound = getHeight() - getPaddingBottom();
    final int left;
    final int right;
    final int top;
    final int bottom;
    if (panel != null && viewIsOpaque(panel)) {
        left = panel.getLeft();/*w ww  . ja v  a  2s.c o  m*/
        right = panel.getRight();
        top = panel.getTop();
        bottom = panel.getBottom();
    } else {
        left = right = top = bottom = 0;
    }

    for (int i = 0, childCount = getChildCount(); i < childCount; i++) {
        final View child = getChildAt(i);

        if (child == panel) {
            // There are still more children above the panel but they won't be affected.
            break;
        }

        final int clampedChildLeft = Math.max(leftBound, child.getLeft());
        final int clampedChildTop = Math.max(topBound, child.getTop());
        final int clampedChildRight = Math.min(rightBound, child.getRight());
        final int clampedChildBottom = Math.min(bottomBound, child.getBottom());
        final int vis;
        if (clampedChildLeft >= left && clampedChildTop >= top && clampedChildRight <= right
                && clampedChildBottom <= bottom) {
            vis = INVISIBLE;
        } else {
            vis = VISIBLE;
        }
        child.setVisibility(vis);
    }
}

From source file:com.apptentive.android.sdk.view.ApptentiveNestedScrollView.java

/**
 * <p>//from w  w w.  j  a  v a2  s  . co  m
 * Finds the next focusable component that fits in the specified bounds.
 * </p>
 *
 * @param topFocus look for a candidate is the one at the top of the bounds
 *                 if topFocus is true, or at the bottom of the bounds if topFocus is
 *                 false
 * @param top      the top offset of the bounds in which a focusable must be
 *                 found
 * @param bottom   the bottom offset of the bounds in which a focusable must
 *                 be found
 * @return the next focusable component in the bounds or null if none can
 *         be found
 */
private View findFocusableViewInBounds(boolean topFocus, int top, int bottom) {

    List<View> focusables = getFocusables(View.FOCUS_FORWARD);
    View focusCandidate = null;

    /*
     * A fully contained focusable is one where its top is below the bound's
     * top, and its bottom is above the bound's bottom. A partially
     * contained focusable is one where some part of it is within the
     * bounds, but it also has some part that is not within bounds.  A fully contained
     * focusable is preferred to a partially contained focusable.
     */
    boolean foundFullyContainedFocusable = false;

    int count = focusables.size();
    for (int i = 0; i < count; i++) {
        View view = focusables.get(i);
        int viewTop = view.getTop();
        int viewBottom = view.getBottom();

        if (top < viewBottom && viewTop < bottom) {
            /*
             * the focusable is in the target area, it is a candidate for
             * focusing
             */

            final boolean viewIsFullyContained = (top < viewTop) && (viewBottom < bottom);

            if (focusCandidate == null) {
                /* No candidate, take this one */
                focusCandidate = view;
                foundFullyContainedFocusable = viewIsFullyContained;
            } else {
                final boolean viewIsCloserToBoundary = (topFocus && viewTop < focusCandidate.getTop())
                        || (!topFocus && viewBottom > focusCandidate.getBottom());

                if (foundFullyContainedFocusable) {
                    if (viewIsFullyContained && viewIsCloserToBoundary) {
                        /*
                         * We're dealing with only fully contained views, so
                         * it has to be closer to the boundary to beat our
                         * candidate
                         */
                        focusCandidate = view;
                    }
                } else {
                    if (viewIsFullyContained) {
                        /* Any fully contained view beats a partially contained view */
                        focusCandidate = view;
                        foundFullyContainedFocusable = true;
                    } else if (viewIsCloserToBoundary) {
                        /*
                         * Partially contained view beats another partially
                         * contained view if it's closer
                         */
                        focusCandidate = view;
                    }
                }
            }
        }
    }

    return focusCandidate;
}

From source file:com.staggeredgrid.library.StaggeredGridView.java

@Override
protected void onChildrenDetached(final int start, final int count) {
    super.onChildrenDetached(start, count);
    // go through our remaining views and sync the top and bottom stash.

    // Repair the top and bottom column boundaries from the views we still have
    Arrays.fill(mColumnTops, Integer.MAX_VALUE);
    Arrays.fill(mColumnBottoms, 0);

    for (int i = 0; i < getChildCount(); i++) {
        final View child = getChildAt(i);
        if (child != null) {
            final LayoutParams childParams = (LayoutParams) child.getLayoutParams();
            if (childParams.viewType != ITEM_VIEW_TYPE_HEADER_OR_FOOTER
                    && childParams instanceof GridLayoutParams) {
                GridLayoutParams layoutParams = (GridLayoutParams) childParams;
                int column = layoutParams.column;
                int position = layoutParams.position;
                final int childTop = child.getTop();
                if (childTop < mColumnTops[column]) {
                    mColumnTops[column] = childTop - getChildTopMargin(position);
                }//from  ww w  .  j a va  2 s  . c  om
                final int childBottom = child.getBottom();
                if (childBottom > mColumnBottoms[column]) {
                    mColumnBottoms[column] = childBottom + getChildBottomMargin();
                }
            } else {
                // the header and footer here
                final int childTop = child.getTop();
                final int childBottom = child.getBottom();

                for (int col = 0; col < mColumnCount; col++) {
                    if (childTop < mColumnTops[col]) {
                        mColumnTops[col] = childTop;
                    }
                    if (childBottom > mColumnBottoms[col]) {
                        mColumnBottoms[col] = childBottom;
                    }
                }

            }
        }
    }
}

From source file:Main.java

private static void expandInner(final View view, final View parentView, final ViewGroup rootContainer,
        final int targtetHeight) {

    setHeight(view, 0);// w ww .j ava 2s .  c om
    view.setVisibility(View.VISIBLE);
    final Animation animation = new Animation() {

        private final Rect rect = new Rect();
        private final Rect parentVisibleRect = new Rect();

        ViewTreeObserver.OnGlobalLayoutListener globalLayoutListener;

        private final Runnable checkViewRunnable = new Runnable() {
            @Override
            public void run() {
                checkForViewInsideVisibleArea();
            }
        };

        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {

            int neededHeight = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT
                    : (int) (targtetHeight * interpolatedTime);
            setHeight(view, neededHeight);

            final ViewTreeObserver viewTreeObserver = view.getViewTreeObserver();

            if (globalLayoutListener == null) {
                globalLayoutListener = new ViewTreeObserver.OnGlobalLayoutListener() {

                    @Override
                    public void onGlobalLayout() {

                        if (globalLayoutListener == null) {
                            removeGlobalLayoutListener(viewTreeObserver, this);
                        }

                        checkForViewInsideVisibleArea();
                    }
                };

                viewTreeObserver.addOnGlobalLayoutListener(globalLayoutListener);
            }

            if (globalLayoutListener != null && interpolatedTime == 1) {
                runInUIThread(checkViewRunnable);
                globalLayoutListener = null;
            }

            view.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }

        private void checkForViewInsideVisibleArea() {

            if (rootContainer.indexOfChild(parentView) == -1) {
                return;
            }

            parentVisibleRect.left = 0;
            parentVisibleRect.top = 0;
            parentVisibleRect.right = parentView.getWidth();
            parentVisibleRect.bottom = parentView.getHeight();

            rootContainer.offsetDescendantRectToMyCoords(parentView, parentVisibleRect);

            if (parentVisibleRect.top < 0 || parentVisibleRect.bottom > rootContainer.getHeight()) {

                rect.left = parentView.getLeft();
                rect.top = parentView.getTop();
                rect.right = parentView.getRight();
                rect.bottom = parentView.getBottom();

                parentView.requestRectangleOnScreen(rect, true);
            }
        }
    };

    animation.setDuration(ANIMATION_DURATION);
    view.startAnimation(animation);
}

From source file:cn.bingoogolapple.swipebacklayout.BGASwipeBackLayout.java

/**
 * Tests scrollability within child views of v given a delta of dx.
 *
 * @param v      View to test for horizontal scrollability
 * @param checkV Whether the view v passed should itself be checked for scrollability (true),
 *               or just its children (false).
 * @param dx     Delta scrolled in pixels
 * @param x      X coordinate of the active touch point
 * @param y      Y coordinate of the active touch point
 * @return true if child views of v can be scrolled by delta of dx.
 *///from  w  w w  . jav a 2 s. c  o  m
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
    if (v instanceof ViewGroup) {
        final ViewGroup group = (ViewGroup) v;
        final int scrollX = v.getScrollX();
        final int scrollY = v.getScrollY();
        final int count = group.getChildCount();
        // Count backwards - let topmost views consume scroll distance first.
        for (int i = count - 1; i >= 0; i--) {
            // TODO: Add versioned support here for transformed views.
            // This will not work for transformed views in Honeycomb+
            final View child = group.getChildAt(i);
            if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight()
                    && y + scrollY >= child.getTop() && y + scrollY < child.getBottom() && canScroll(child,
                            true, dx, x + scrollX - child.getLeft(), y + scrollY - child.getTop())) {
                return true;
            }
        }
    }

    return checkV && ViewCompat.canScrollHorizontally(v, (isLayoutRtlSupport() ? dx : -dx));
}