Example usage for android.view View getRight

List of usage examples for android.view View getRight

Introduction

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

Prototype

@ViewDebug.CapturedViewProperty
public final int getRight() 

Source Link

Document

Right position of this view relative to its parent.

Usage

From source file:com.kayac.slidingmenu.ui.views.DraggableLayout.java

/**
 * Detect at a specific position of view, its child can scrollHoziontally or not
 * Also support Viewpager as its child//from w  ww.j  a  v  a 2s.c om
 * @param v         view to check
 * @param checkV   check it or not
 * @param dx      Direction
 * @param x         pos X
 * @param y         pos Y
 * @return
 */
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();
        for (int i = count - 1; i >= 0; i--) {
            final View child = group.getChildAt(i);
            if (child.getVisibility() == View.VISIBLE && 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) || (v instanceof ViewPager)));
}

From source file:com.azhansy.linky.view.PagerSlidingIndicator.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isInEditMode()) {
        return;//ww w . j a  va  2 s. com
    }

    final int height = getHeight();
    float radius = height / 2.0f;

    drawBackground(canvas);

    if (pager != null) {

        // default: line below current tab
        View currentTab = tabsContainer.getChildAt(currentPosition);
        float lineLeft = currentTab.getLeft();
        float lineRight = currentTab.getRight();

        // if there is an offset, start interpolating left and right coordinates between current and next tab
        if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {

            View nextTab = tabsContainer.getChildAt(currentPosition + 1);
            final float nextTabLeft = nextTab.getLeft();
            final float nextTabRight = nextTab.getRight();

            lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
            lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
        }

        mTempRectF.set(lineLeft, 0, lineRight, height);
        checkedBackgroundPaint.setColor(checkedBackgroundColor);
        canvas.drawRoundRect(mTempRectF, radius, radius, checkedBackgroundPaint);

        updateTextColor();

    } else {
        View tab = tabsContainer.getChildAt(mNoPagerPosition);
        float lineLeft = tab.getLeft();
        float lineRight = tab.getRight();

        mTempRectF.set(lineLeft, 0, lineRight, height);
        checkedBackgroundPaint.setColor(checkedBackgroundColor);
        canvas.drawRoundRect(mTempRectF, radius, radius, checkedBackgroundPaint);
    }
}

From source file:bigshots.people_helping_people.scroll_iew_lib.PagerSlidingTabStrip.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isInEditMode() || tabCount == 0) {
        return;//w  w  w .j  a  v  a2s. com
    }

    final int height = getHeight();

    // draw indicator line

    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();

    // if there is an offset, start interpolating left and right coordinates between current and next tab
    if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {
        View nextTab = tabsContainer.getChildAt(currentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }
    canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);

    // draw underline

    rectPaint.setColor(underlineColor);
    canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);

    // draw divider

    dividerPaint.setColor(dividerColor);
    for (int i = 0; i < tabCount - 1; i++) {
        View tab = tabsContainer.getChildAt(i);
        canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
    }

    updateTextColor();
}

From source file:catchla.yep.adapter.decorator.DividerItemDecoration.java

public void drawHorizontal(Canvas c, RecyclerView parent) {
    if (mDivider == null)
        return;/*from ww w  .j  ava 2  s  .  c  o  m*/
    final int top = parent.getPaddingTop();
    final int bottom = parent.getHeight() - parent.getPaddingBottom();

    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        final int childPos = parent.getChildAdapterPosition(child);
        final int start = getDecorationStart(), end = getDecorationEnd(parent);
        if (start >= 0 && childPos < start || end >= 0 && childPos > end)
            continue;
        final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
        final int left = child.getRight() + params.rightMargin + Math.round(ViewCompat.getTranslationX(child));
        final int right = left + mDivider.getIntrinsicHeight();
        mDivider.setBounds(left + mPadding.left, top + mPadding.top, right - mPadding.right,
                bottom - mPadding.bottom);
        mDivider.draw(c);
    }
}

From source file:com.dm.xz.views.PinnedSectionListView.java

public void setShadowVisible(boolean visible) {
    initShadow(visible);//from w w  w  . j  av  a 2s.  c  om
    if (mPinnedSection != null) {
        View v = mPinnedSection.view;
        invalidate(v.getLeft(), v.getTop(), v.getRight(), v.getBottom() + mShadowHeight);
    }
}

From source file:com.haarman.listviewanimations.itemmanipulation.SwipeDismissListViewTouchListener.java

private Rect getChildViewRect(View parentView, View childView) {
    final Rect childRect = new Rect(childView.getLeft(), childView.getTop(), childView.getRight(),
            childView.getBottom());//from  ww  w .  j  av a  2s.co m
    if (parentView == childView) {
        return childRect;

    }

    ViewGroup parent;
    while ((parent = (ViewGroup) childView.getParent()) != parentView) {
        childRect.offset(parent.getLeft(), parent.getTop());
        childView = parent;
    }

    return childRect;
}

From source file:com.hippo.nimingban.widget.PostLayout.java

@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
    boolean result = super.drawChild(canvas, child, drawingTime);
    int top = child.getTop();
    if (1 == indexOfChild(child) && top > 0) {
        mShadowTop.setBounds(0, top - mShadowHeight, child.getRight(), top);
        mShadowTop.draw(canvas);/*from  w  ww  .  j  ava  2s .co  m*/
    }
    return result;
}

From source file:com.goforer.base.ui.helper.RecyclerItemTouchHelperCallback.java

@Override
public void onChildDraw(Canvas canvas, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX,
        float dY, int actionState, boolean isCurrentlyActive) {
    if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
        View itemView = viewHolder.itemView;

        // not sure why, but this method get's called for viewholder that are already swiped away
        if (viewHolder.getAdapterPosition() == -1) {
            // not interested in those
            return;
        }//  w w  w  .j a  v  a  2 s  . co m

        if (!mInitiated) {
            init();
        }

        // draw red background
        mBackground.setBounds(itemView.getRight() + (int) dX, itemView.getTop(), itemView.getRight(),
                itemView.getBottom());
        mBackground.draw(canvas);

        // draw delete-icon
        int itemHeight = itemView.getBottom() - itemView.getTop();
        int intrinsicWidth = mDeleteIcon.getIntrinsicWidth();
        int intrinsicHeight = mDeleteIcon.getIntrinsicWidth();

        int xMarkLeft = itemView.getRight() - mDeleteIconMargin - intrinsicWidth;
        int xMarkRight = itemView.getRight() - mDeleteIconMargin;
        int xMarkTop = itemView.getTop() + (itemHeight - intrinsicHeight) / 2;
        int xMarkBottom = xMarkTop + intrinsicHeight;

        mDeleteIcon.setBounds(xMarkLeft, xMarkTop, xMarkRight, xMarkBottom);
        mDeleteIcon.draw(canvas);

        // Fade out the view as it is swiped out of the parent's bounds
        final float alpha = ALPHA_FULL - Math.abs(dX) / (float) viewHolder.itemView.getWidth();
        viewHolder.itemView.setAlpha(alpha);
        viewHolder.itemView.setTranslationX(dX);

    } else {
        super.onChildDraw(canvas, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
    }
}

From source file:com.example.testing.myapplication.module.pageSliding.PagerSlidingTabStrip.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isInEditMode() || tabCount == 0) {
        return;//from   w  w w  . j a v  a 2 s.  c o m
    }

    final int height = getHeight();

    // draw indicator line

    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    int lineLeft = currentTab.getLeft();
    int lineRight = currentTab.getRight();

    //if there is an offset, start interpolating left and right coordinates between current and next tab
    if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {

        View nextTab = tabsContainer.getChildAt(currentPosition + 1);
        int nextTabLeft = nextTab.getLeft();
        int nextTabRight = nextTab.getRight();

        lineLeft = (int) (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (int) (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }

    lineLeft += (int) ((lineRight - lineLeft - indicator_width) / 2 + 0.5);
    lineRight = lineLeft + indicator_width;

    canvas.drawRect(lineLeft, height - indicatorHeight - indicator_bottom_margin, lineRight,
            height - indicator_bottom_margin, rectPaint);

    // draw underline

    //rectPaint.setColor(underlineColor);
    //canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);

    // draw divider

    //dividerPaint.setColor(dividerColor);
    //for (int i = 0; i < tabCount - 1; i++) {
    //    View tab = tabsContainer.getChildAt(i);
    //    canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
    //}
}

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;
        }/*  w w w  .  j a  v  a 2  s .  c  o m*/
        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);
        }
    }
}