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.freud.mrzz.views.PagerSlidingTabStrip.java

private Pair<Float, Float> getIndicatorCoordinates() {
    // default: line below current pager_sliding_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 pager_sliding_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);
    }/*from  w w w.ja  v a  2 s.c  o  m*/
    return new Pair<Float, Float>(lineLeft, lineRight);
}

From source file:com.bwash.bwashcar.view.PagerSlidingTabStrip.java

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

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

    final int height = getHeight();

    // draw indicator line

    rectPaint.setColor(indicatorColor);

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

    // 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() + indicatorOffWidth;
        final float nextTabRight = nextTab.getRight() - indicatorOffWidth;

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

From source file:com.github.shareme.gwspagerslidingtabstrip.library.PagerSlidingTabStrip.java

private Pair<Float, Float> getIndicatorCoordinates() {
    // default: line below current tab
    View currentTab = mTabsContainer.getChildAt(mCurrentPosition);
    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 (mCurrentPositionOffset > 0f && mCurrentPosition < mTabCount - 1) {
        View nextTab = mTabsContainer.getChildAt(mCurrentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();
        lineLeft = (mCurrentPositionOffset * nextTabLeft + (1f - mCurrentPositionOffset) * lineLeft);
        lineRight = (mCurrentPositionOffset * nextTabRight + (1f - mCurrentPositionOffset) * lineRight);
    }//  w  ww.  j  av a  2s  .  c o  m

    return new Pair<>(lineLeft, lineRight);
}

From source file:com.example.administrator.common.widget.swipeback.SwipeBackLayout.java

private void drawScrim(Canvas canvas, View child) {
    final int baseAlpha = (mScrimColor & 0xff000000) >>> 24;
    final int alpha = (int) (baseAlpha * mScrimOpacity);
    final int color = alpha << 24 | (mScrimColor & 0xffffff);

    if ((mTrackingEdge & EDGE_LEFT) != 0) {
        canvas.clipRect(0, 0, child.getLeft(), getHeight());
    } else if ((mTrackingEdge & EDGE_RIGHT) != 0) {
        canvas.clipRect(child.getRight(), 0, getRight(), getHeight());
    } else if ((mTrackingEdge & EDGE_BOTTOM) != 0) {
        canvas.clipRect(child.getLeft(), child.getBottom(), getRight(), getHeight());
    } else if ((mTrackingEdge & EDGE_TOP) != 0) {
        canvas.clipRect(0, child.getTop(), 0, getHeight());
    }//from  w w  w  . j  a  v  a  2  s. co m
    canvas.drawColor(color);
}

From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java

/**
 * changes the page./*from   ww  w. ja v  a2s  . co  m*/
 *
 * @param position the page to go to.
 * @param clicked  if true, the viewPager is set to the position
 */
private void changePage(final int position, boolean clicked, boolean force) {
    if (images.size() > 1 && (force || current != position)) {
        Log.d("SEND_IMAGE", "page changed");
        images.get(current).getBackground().setVisibility(View.GONE);
        images.get(position).getBackground().setVisibility(View.VISIBLE);
        current = position;
        // scroll to correct position
        HorizontalScrollView scrollView = (HorizontalScrollView) getActivity()
                .findViewById(R.id.send_image_overview);
        View view = images.get(current).getLayout();
        int vLeft = view.getLeft();
        int vRight = view.getRight();
        int sWidth = scrollView.getWidth();
        if (!isViewVisible(scrollView, view))
            scrollView.smoothScrollTo((vLeft + vRight - sWidth) / 2, 0);
        if (clicked)
            // setting the viewPagers item is posted via a handler, so the gui
            // thread finishes the scrollView related task before switching the
            // viewPager. That way it seems smoother because the new image is
            // selected instantly.
            new Handler().post(new Runnable() {
                @Override
                public void run() {
                    viewPager.setCurrentItem(position);
                }
            });
    }
}

From source file:com.github.shareme.gwsmaterialuikit.library.material.widget.TabIndicatorView.java

protected void onTabScrollStateChanged(int state) {
    if (mCenterCurrentTab) {
        if (state == SCROLL_STATE_IDLE) {
            if (!mScrollingToCenter) {
                View v = mLayoutManager.findViewByPosition(mSelectedPosition);
                if (v != null) {
                    int viewCenter = (v.getLeft() + v.getRight()) / 2;
                    int parentCenter = (getLeft() + getPaddingLeft() + getRight() - getPaddingRight()) / 2;
                    int scrollNeeded = viewCenter - parentCenter;
                    if (scrollNeeded != 0) {
                        smoothScrollBy(scrollNeeded, 0);
                        mScrollingToCenter = true;
                    }//from   w w  w .j  a v  a 2  s  .  co  m
                }
            }
        }

        if (state == SCROLL_STATE_DRAGGING || state == SCROLL_STATE_SETTLING)
            mScrollingToCenter = false;
    }

    if (state == ViewPager.SCROLL_STATE_IDLE) {
        mScrolling = false;
        View v = mLayoutManager.findViewByPosition(mSelectedPosition);
        updateIndicator(v);
    } else
        mScrolling = true;
}

From source file:com.cc.custom.uikit.PagerSlidingTabStrip.java

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

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

    final int height = getHeight();

    View currentTab = tabsContainer.getChildAt(firstPosition);

    // draw indicator line

    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    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 (firstPositionOffset > 0f && firstPosition < tabCount - 1) {

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

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

    canvas.drawRect(lineLeft + indicatorPadding, height - indicatorHeight, lineRight - indicatorPadding, 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);
    }

}

From source file:com.android.photos.views.GalleryThumbnailView.java

final void offsetChildren(int offset) {
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = getChildAt(i);
        child.layout(child.getLeft() + offset, child.getTop(), child.getRight() + offset, child.getBottom());
    }/*ww  w . j ava2s  . co m*/
}

From source file:com.homechart.app.commont.matertab.MaterialTabs.java

private Pair<Float, Float> getIndicatorCoordinates() {
    // Default: line is 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);
    }//from w ww . j  a  v a 2s  .co  m
    return new Pair<>(lineLeft, lineRight);
}

From source file:com.example.carlitos.swipeitemrecycler.view.animation.swipe_item.swipeable.ItemSlidingAnimator.java

private boolean slideToOutsideOfWindowInternal(RecyclerView.ViewHolder holder, int dir, boolean shouldAnimate,
        long duration, SwipeFinishInfo swipeFinish) {

    if (!(holder instanceof SwipeableItemViewHolder)) {
        return false;
    }/*w  w  w.ja  v  a  2 s .  c  om*/

    final View containerView = ((SwipeableItemViewHolder) holder).getSwipeableContainerView();
    final ViewGroup parent = (ViewGroup) containerView.getParent();

    if (parent == null) {
        return false;
    }

    final int left = containerView.getLeft();
    final int right = containerView.getRight();
    final int top = containerView.getTop();
    final int bottom = containerView.getBottom();
    final int width = right - left;
    final int height = bottom - top;
    final boolean parentIsShown = parent.isShown();

    parent.getWindowVisibleDisplayFrame(mTmpRect);
    final int windowWidth = mTmpRect.width();
    final int windowHeight = mTmpRect.height();

    int translateX = 0;
    int translateY = 0;

    if ((width == 0) || (height == 0) || !parentIsShown) {
        // not measured yet or not shown
        switch (dir) {
        case DIR_LEFT:
            translateX = -windowWidth;
            break;
        case DIR_UP:
            translateY = -windowHeight;
            break;
        case DIR_RIGHT:
            translateX = windowWidth;
            break;
        case DIR_DOWN:
            translateY = windowHeight;
            break;
        default:
            break;
        }
        shouldAnimate = false;
    } else {
        parent.getLocationInWindow(mTmpLocation);
        final int x = mTmpLocation[0];
        final int y = mTmpLocation[1];

        switch (dir) {
        case DIR_LEFT:
            translateX = -(x + width);
            break;
        case DIR_UP:
            translateY = -(y + height);
            break;
        case DIR_RIGHT:
            translateX = windowWidth - (x - left);
            break;
        case DIR_DOWN:
            translateY = windowHeight - (y - top);
            break;
        default:
            break;
        }
    }

    if (shouldAnimate) {
        shouldAnimate = containerView.isShown();
    }

    duration = (shouldAnimate) ? duration : 0;

    boolean horizontal = (dir == DIR_LEFT || dir == DIR_RIGHT);
    return animateSlideInternalCompat(holder, horizontal, translateX, translateY, duration,
            mSlideToOutsideOfWindowAnimationInterpolator, swipeFinish);
}