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.astuetz.PagerSlidingTabStripPlus.java

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

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

    final int height = getHeight();

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

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

    // draw indicator line
    rectPaint.setColor(Color.argb(indicatorAlpha, Color.red(indicatorColor), Color.green(indicatorColor),
            Color.blue(indicatorColor)));
    canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);

    // draw divider
    if (hasDivider) {
        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.bei.test.view.tab.PagerSlidingTabStrip.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (isInEditMode() || mTabCount == 0) {
        return;//from   w  w  w. ja va 2 s.c  o  m
    }

    final int height = getHeight();
    // draw divider
    if (mDividerWidth > 0) {
        mDividerPaint.setStrokeWidth(mDividerWidth);
        mDividerPaint.setColor(mDividerColor);
        for (int i = 0; i < mTabCount - 1; i++) {
            View tab = mTabsContainer.getChildAt(i);
            canvas.drawLine(tab.getRight(), mDividerPadding, tab.getRight(), height - mDividerPadding,
                    mDividerPaint);
        }
    }

    // draw underline
    if (mUnderlineHeight > 0) {
        mRectPaint.setColor(mUnderlineColor);
        canvas.drawRect(mPaddingLeft, height - mUnderlineHeight, mTabsContainer.getWidth() + mPaddingRight,
                height, mRectPaint);
    }

    // draw indicator line
    if (mIndicatorHeight > 0) {
        mRectPaint.setColor(mIndicatorColor);
        Pair<Float, Float> lines = getIndicatorCoordinates();
        canvas.drawRect(lines.first + mPaddingLeft, height - mIndicatorHeight, lines.second + mPaddingLeft,
                height, mRectPaint);
    }
}

From source file:com.h6ah4i.android.materialshadowninepatch.MaterialShadowContainerView.java

private void updateShadowDrawableBounds() {
    if (getChildCount() <= 0) {
        return;/*  ww  w.  ja v a  2  s.c  o  m*/
    }

    final View childView = getChildAt(0);

    final int childLeft = childView.getLeft();
    final int childTop = childView.getTop();
    final int childRight = childView.getRight();
    final int childBottom = childView.getBottom();

    updateNinePatchBounds(mCurrentSpotShadowDrawable1, childLeft, childTop, childRight, childBottom);
    if (mCurrentAmbientShadowDrawable1 != mCurrentSpotShadowDrawable2) {
        updateNinePatchBounds(mCurrentSpotShadowDrawable2, childLeft, childTop, childRight, childBottom);
    }

    updateNinePatchBounds(mCurrentAmbientShadowDrawable1, childLeft, childTop, childRight, childBottom);
    if (mCurrentAmbientShadowDrawable1 != mCurrentAmbientShadowDrawable2) {
        updateNinePatchBounds(mCurrentAmbientShadowDrawable2, childLeft, childTop, childRight, childBottom);
    }
}

From source file:com.google.samples.apps.iosched.ui.SearchActivity.java

/**
 * On Lollipop+ perform a circular animation (a contracting circular mask) when hiding the
 * search panel./*from w ww  .ja va  2 s  .  c  om*/
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doExitAnim() {
    final View searchPanel = findViewById(R.id.search_panel);
    // Center the animation on the top right of the panel i.e. near to the search button which
    // launched this screen. The starting radius therefore is the diagonal distance from the top
    // right to the bottom left
    int revealRadius = (int) Math
            .sqrt(Math.pow(searchPanel.getWidth(), 2) + Math.pow(searchPanel.getHeight(), 2));
    // Animating the radius to 0 produces the contracting effect
    Animator shrink = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(),
            searchPanel.getTop(), revealRadius, 0f);
    shrink.setDuration(200L);
    shrink.setInterpolator(
            AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in));
    shrink.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            searchPanel.setVisibility(View.INVISIBLE);
            ActivityCompat.finishAfterTransition(SearchActivity.this);
        }
    });
    shrink.start();

    // We also animate out the translucent background at the same time.
    findViewById(R.id.scrim).animate().alpha(0f).setDuration(200L).setInterpolator(
            AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in))
            .start();
}

From source file:com.ashish.routofy.PagerSlidingTabStrip.java

private Pair<Float, Float> getIndicatorCoordinates() {
    // 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);
    }//from ww w.  j  av a2 s. co  m
    return new Pair<Float, Float>(lineLeft, lineRight);
}

From source file:com.ghkjgod.lightnovel.component.PagerSlidingTabStrip.java

private Pair<Float, Float> getIndicatorCoordinates() {
    // default: line below current view_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 view_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 ww  w. j a  v  a2  s . c  om
    return new Pair<>(lineLeft, lineRight);
}

From source file:cn.liucl.stationarytabstrip.PagerSlidingTabStrip.java

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

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

    int height = getHeight();

    // draw indicator line
    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    float lineLeft;
    float lineRight;
    View currentTabView;
    if (currentPosition < headsContainer.getChildCount()) {
        currentTabView = headsContainer.getChildAt(currentPosition);
        lineLeft = currentTabView.getLeft();
        lineRight = currentTabView.getRight();
    } else {
        currentTabView = tabsContainer.getChildAt(currentPosition - headsContainer.getChildCount());
        lineLeft = currentTabView.getLeft() + headsContainerMeasuredWidth;
        lineRight = currentTabView.getRight() + headsContainerMeasuredWidth;
    }

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

        View nextTab;
        float nextTabLeft;
        float nextTabRight;
        if (currentPosition < headsContainer.getChildCount()) {
            if (currentPosition == headsContainer.getChildCount() - 1) {
                nextTab = tabsContainer.getChildAt(0);
                nextTabLeft = nextTab.getLeft() + headsContainerMeasuredWidth;
                nextTabRight = nextTab.getRight() + headsContainerMeasuredWidth;
            } else {
                nextTab = headsContainer.getChildAt(currentPosition + 1);
                nextTabLeft = nextTab.getLeft();
                nextTabRight = nextTab.getRight();
            }
        } else {
            nextTab = tabsContainer.getChildAt(currentPosition - headsContainer.getChildCount() + 1);
            nextTabLeft = nextTab.getLeft() + headsContainerMeasuredWidth;
            nextTabRight = nextTab.getRight() + headsContainerMeasuredWidth;
        }

        lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
        lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
    }
    float left = lineLeft + indicatorOffset;
    float right = lineRight + indicatorOffset;
    if (isScrolling && left < headsContainerMeasuredWidth
            && currentPosition > headsContainer.getChildCount() - 1) {
        left = headsContainerMeasuredWidth;
    }
    canvas.drawRect(left, height - indicatorHeight, right, height, rectPaint);
}

From source file:com.mingle.discolor.PagerSlidingTabStrip.java

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

    if (isInEditMode() || tabCount == 0) {
        return;//w w  w . ja v a2s.co 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();
    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);
    }
}

From source file:app.newbee.lib.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());
    }/*  www  .j  av  a2  s .  c o m*/
    canvas.drawColor(color);
}

From source file:com.bei.test.view.tab.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);
    }//from w  w  w  .ja  va  2 s.  com

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