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.study.newsclient.pages.design.behavior.helper.HeaderScrollingViewBehavior.java

@Override
protected void layoutChild(final CoordinatorLayout parent, final View child, final int layoutDirection) {
    final List<View> dependencies = parent.getDependencies(child);
    final View header = findFirstDependency(dependencies);

    if (header != null) {
        final CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
        final Rect available = mTempRect1;
        available.set(parent.getPaddingLeft() + lp.leftMargin, header.getBottom() + lp.topMargin,
                parent.getWidth() - parent.getPaddingRight() - lp.rightMargin,
                parent.getHeight() + header.getBottom() - parent.getPaddingBottom() - lp.bottomMargin);

        /* final WindowInsetsCompat parentInsets = parent.getLastWindowInsets();
         if (parentInsets != null && ViewCompat.getFitsSystemWindows(parent)
            && !ViewCompat.getFitsSystemWindows(child)) {
        // If we're set to handle insets but this child isn't, then it has been measured as
        // if there are no insets. We need to lay it out to match horizontally.
        // Top and bottom and already handled in the logic above
        available.left += parentInsets.getSystemWindowInsetLeft();
        available.right -= parentInsets.getSystemWindowInsetRight();
         }*//*from w w  w  . java2  s . com*/

        final Rect out = mTempRect2;
        GravityCompat.apply(resolveGravity(lp.gravity), child.getMeasuredWidth(), child.getMeasuredHeight(),
                available, out, layoutDirection);

        final int overlap = getOverlapPixelsForOffset(header);

        child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap);
        mVerticalLayoutGap = out.top - header.getBottom();
    } else {
        // If we don't have a dependency, let super handle it
        super.layoutChild(parent, child, layoutDirection);
        mVerticalLayoutGap = 0;
    }
}

From source file:com.example.sergey.currentweather.ui.fragment.MainFragment.java

private void initSwipe() {
    ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0,
            ItemTouchHelper.LEFT) {/*from   w  ww  .java2s .co  m*/

        @Override
        public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                RecyclerView.ViewHolder target) {
            return false;
        }

        @Override
        public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
            int position = viewHolder.getAdapterPosition();
            if (direction == ItemTouchHelper.LEFT) {
                deleteData(mCityListAdapter.removeItem(position));
            }
        }

        @Override
        public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
                float dX, float dY, int actionState, boolean isCurrentlyActive) {
            Bitmap icon;
            if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
                View itemView = viewHolder.itemView;
                float height = (float) itemView.getBottom() - (float) itemView.getTop();
                float width = height / 3;
                if (dX < 0) {
                    mPoint.setColor(Color.parseColor("#D32F2F"));
                    RectF background = new RectF((float) itemView.getRight() + dX, (float) itemView.getTop(),
                            (float) itemView.getRight(), (float) itemView.getBottom());
                    c.drawRect(background, mPoint);
                    icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_delete_white);
                    RectF icon_dest = new RectF((float) itemView.getRight() - 2 * width,
                            (float) itemView.getTop() + width, (float) itemView.getRight() - width,
                            (float) itemView.getBottom() - width);
                    c.drawBitmap(icon, null, icon_dest, mPoint);
                }
            }
            super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
        }
    };
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
    itemTouchHelper.attachToRecyclerView(mRecyclerView);
}

From source file:android.support.v7.internal.widget.ListViewCompat.java

protected void positionSelectorCompat(int position, View sel) {
    final Rect selectorRect = mSelectorRect;
    selectorRect.set(sel.getLeft(), sel.getTop(), sel.getRight(), sel.getBottom());

    // Adjust for selection padding.
    selectorRect.left -= mSelectionLeftPadding;
    selectorRect.top -= mSelectionTopPadding;
    selectorRect.right += mSelectionRightPadding;
    selectorRect.bottom += mSelectionBottomPadding;

    try {//from  w  w w.  ja v  a 2 s.  c om
        // AbsListView.mIsChildViewEnabled controls the selector's state so we need to
        // modify it's value
        final boolean isChildViewEnabled = mIsChildViewEnabled.getBoolean(this);
        if (sel.isEnabled() != isChildViewEnabled) {
            mIsChildViewEnabled.set(this, !isChildViewEnabled);
            if (position != INVALID_POSITION) {
                refreshDrawableState();
            }
        }
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:com.huyn.demogroup.bahavior.widget.HeaderScrollingViewBehavior.java

@Override
protected void layoutChild(final CoordinatorLayout parent, final View child, final int layoutDirection) {
    final List<View> dependencies = parent.getDependencies(child);
    final View header = findFirstDependency(dependencies);

    if (header != null) {
        final CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
        final Rect available = mTempRect1;
        SysoutUtil.sysout("HeaderScrollingViewBehavior", "layoutChild", "header.bottom:" + header.getBottom());
        available.set(parent.getPaddingLeft() + lp.leftMargin, header.getBottom() + lp.topMargin,
                parent.getWidth() - parent.getPaddingRight() - lp.rightMargin,
                parent.getHeight() + header.getBottom() - parent.getPaddingBottom() - lp.bottomMargin);

        final WindowInsetsCompat parentInsets = parent.getLastWindowInsets();
        if (parentInsets != null && ViewCompat.getFitsSystemWindows(parent)
                && !ViewCompat.getFitsSystemWindows(child)) {
            // If we're set to handle insets but this child isn't, then it has been measured as
            // if there are no insets. We need to lay it out to match horizontally.
            // Top and bottom and already handled in the logic above
            available.left += parentInsets.getSystemWindowInsetLeft();
            available.right -= parentInsets.getSystemWindowInsetRight();
        }//from ww w.  ja v  a2 s .  c  om

        final Rect out = mTempRect2;
        GravityCompat.apply(resolveGravity(lp.gravity), child.getMeasuredWidth(), child.getMeasuredHeight(),
                available, out, layoutDirection);

        final int overlap = getOverlapPixelsForOffset(header);

        child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap);
        mVerticalLayoutGap = out.top - header.getBottom();
    } else {
        // If we don't have a dependency, let super handle it
        super.layoutChild(parent, child, layoutDirection);
        mVerticalLayoutGap = 0;
    }
}

From source file:ameircom.keymedia.Activity.transition.FabTransform.java

private void captureValues(TransitionValues transitionValues) {
    final View view = transitionValues.view;
    if (view == null || view.getWidth() <= 0 || view.getHeight() <= 0)
        return;/*from w  w  w.ja v  a  2  s . c  o m*/

    transitionValues.values.put(PROP_BOUNDS,
            new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()));
}

From source file:com.wmstein.transektcount.EditSectionActivity.java

public void ScrollToEndOfView(View scrlV) {
    int scroll_amount = scrlV.getBottom();
    int scrollY = scroll_amount;
    boolean pageend = false;
    while (!pageend) {
        scrlV.scrollTo(0, scroll_amount); //scroll
        scroll_amount = scroll_amount + scroll_amount; //increase scroll_amount 
        scrollY = scrollY + scrlV.getScrollY(); //scroll position 1. row
        if (scroll_amount > scrollY) {
            pageend = true;//w  w w . j  a va 2s .c  o  m
        }
    }
}

From source file:com.mad.splitlist.util.DividerItemDecoration.java

@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
    final int offset = (int) (mPaint.getStrokeWidth() / DIVIDE_OFFSET);

    for (int i = 0; i < parent.getChildCount(); i++) {
        final View view = parent.getChildAt(i);
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();

        final int position = params.getViewAdapterPosition();

        // Draw separator using paint.
        if (position < state.getItemCount()) {
            // apply alpha to support animations
            mPaint.setAlpha((int) (view.getAlpha() * mAlpha));

            float positionY = view.getBottom() + offset + view.getTranslationY();
            // do the drawing
            c.drawLine(view.getLeft() + view.getTranslationX(), positionY,
                    view.getRight() + view.getTranslationX(), positionY, mPaint);
        }//from   ww  w.ja v a  2 s .  c o m
    }
}

From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.decoration.SimpleListDividerDecorator.java

@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    final int childCount = parent.getChildCount();

    if (childCount == 0) {
        return;//from   w ww.j a  v a2 s.c om
    }

    final float xPositionThreshold = (mOverlap) ? 1.0f : (mVerticalDividerWidth + 1.0f); // [px]
    final float yPositionThreshold = (mOverlap) ? 1.0f : (mHorizontalDividerHeight + 1.0f); // [px]
    final float zPositionThreshold = 1.0f; // [px]

    for (int i = 0; i < childCount - 1; i++) {
        final View child = parent.getChildAt(i);
        final View nextChild = parent.getChildAt(i + 1);

        if ((child.getVisibility() != View.VISIBLE) || (nextChild.getVisibility() != View.VISIBLE)) {
            continue;
        }

        // check if the next item is placed at the bottom or right
        final float childBottom = child.getBottom() + ViewCompat.getTranslationY(child);
        final float nextChildTop = nextChild.getTop() + ViewCompat.getTranslationY(nextChild);
        final float childRight = child.getRight() + ViewCompat.getTranslationX(child);
        final float nextChildLeft = nextChild.getLeft() + ViewCompat.getTranslationX(nextChild);

        if (!(((mHorizontalDividerHeight != 0) && (Math.abs(nextChildTop - childBottom) < yPositionThreshold))
                || ((mVerticalDividerWidth != 0)
                        && (Math.abs(nextChildLeft - childRight) < xPositionThreshold)))) {
            continue;
        }

        // check if the next item is placed on the same plane
        final float childZ = ViewCompat.getTranslationZ(child) + ViewCompat.getElevation(child);
        final float nextChildZ = ViewCompat.getTranslationZ(nextChild) + ViewCompat.getElevation(nextChild);

        if (!(Math.abs(nextChildZ - childZ) < zPositionThreshold)) {
            continue;
        }

        final float childAlpha = ViewCompat.getAlpha(child);
        final float nextChildAlpha = ViewCompat.getAlpha(nextChild);

        final int tx = (int) (ViewCompat.getTranslationX(child) + 0.5f);
        final int ty = (int) (ViewCompat.getTranslationY(child) + 0.5f);

        if (mHorizontalDividerHeight != 0) {
            final int left = child.getLeft();
            final int right = child.getRight();
            final int top = child.getBottom() - (mOverlap ? mHorizontalDividerHeight : 0);
            final int bottom = top + mHorizontalDividerHeight;

            mHorizontalDrawable.setAlpha((int) ((0.5f * 255) * (childAlpha + nextChildAlpha) + 0.5f));
            mHorizontalDrawable.setBounds(left + tx, top + ty, right + tx, bottom + ty);
            mHorizontalDrawable.draw(c);
        }

        if (mVerticalDividerWidth != 0) {
            final int left = child.getRight() - (mOverlap ? mVerticalDividerWidth : 0);
            final int right = left + mVerticalDividerWidth;
            final int top = child.getTop();
            final int bottom = child.getBottom();

            mVerticalDrawable.setAlpha((int) ((0.5f * 255) * (childAlpha + nextChildAlpha) + 0.5f));
            mVerticalDrawable.setBounds(left + tx, top + ty, right + tx, bottom + ty);
            mVerticalDrawable.draw(c);
        }
    }
}

From source file:com.n3rditorium.pocketdoggie.transitions.FabTransform.java

private void captureValues(TransitionValues transitionValues) {
    final View view = transitionValues.view;
    if (view == null || view.getWidth() <= 0 || view.getHeight() <= 0) {
        return;/*from   w ww .ja  va2s  .  co  m*/
    }

    transitionValues.values.put(PROP_BOUNDS,
            new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()));
}

From source file:com.merlin.view.recycler.RecyclerListDecoration.java

public void drawHorizontal(Canvas c, RecyclerView parent) {
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        if (isHideDivider(parent, parent.getChildLayoutPosition(child), parent.getAdapter().getItemCount())) {
            continue;
        }//from  w  ww.  j a  v a2  s .c  om
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int top = child.getTop() - params.topMargin;
        final int bottom = child.getBottom() + params.bottomMargin;
        final int left = child.getRight() + params.rightMargin + Math.round(ViewCompat.getTranslationX(child));
        final int right = left + mHeight;

        if (mDivider == null) {
            c.drawRect(left, top, right, bottom, dividerPaint);
        } else {
            mDivider.setBounds(left, top, right, bottom);
            mDivider.draw(c);
        }
    }
}