Example usage for android.view View getLeft

List of usage examples for android.view View getLeft

Introduction

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

Prototype

@ViewDebug.CapturedViewProperty
public final int getLeft() 

Source Link

Document

Left position of this view relative to its parent.

Usage

From source file:com.almeida.matheus.androidslidingtabmaterialdesigner.Components.SlidingTabLayout.java

private void scrollToTab(int tabIndex, int positionOffset) {
    final int tabStripChildCount = mTabStrip.getChildCount();
    if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
        return;/*from  ww w .  j a va  2s. c  o m*/
    }
    View selectedChild = mTabStrip.getChildAt(tabIndex);
    if (selectedChild != null) {
        int targetScrollX = selectedChild.getLeft() + positionOffset;

        if (tabIndex > 0 || positionOffset > 0) {
            // If we're not at the first child and are mid-scroll, make sure we obey the offset
            targetScrollX -= mTitleOffset;
        }

        scrollTo(targetScrollX, 0);
    }
}

From source file:com.android.yijiang.kzx.widget.betterpickers.widget.UnderlinePageIndicatorPicker.java

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

    final int count = mViewPager.getAdapter().getCount();

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

    if (mTitleView != null) {
        View currentTab = mTitleView.getViewAt(mCurrentPage);
        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 (mPositionOffset > 0f && mCurrentPage < count - 1) {

            View nextTab = mTitleView.getViewAt(mCurrentPage + 1);
            final float nextTabLeft = nextTab.getLeft();
            final float nextTabRight = nextTab.getRight();

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

        canvas.drawRect(lineLeft, getPaddingBottom(), lineRight, getHeight() - getPaddingBottom(), mPaint);
    }
}

From source file:acc.healthapp.tabs.SlidingTabLayout.java

private void scrollToTab(int tabIndex, int positionOffset) {
    final int tabStripChildCount = mTabStrip.getChildCount();
    if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
        return;/*from  w  w w.j a va  2s .c om*/
    }

    View selectedChild = mTabStrip.getChildAt(tabIndex);
    if (selectedChild != null) {
        int targetScrollX = selectedChild.getLeft() + positionOffset;

        if (tabIndex > 0 || positionOffset > 0) {
            // If we're not at the first child and are mid-scroll, make sure we obey the offset
            targetScrollX -= mTitleOffset;
        }

        scrollTo(targetScrollX, 0);
    }
}

From source file:com.appsimobile.view.SlidingTabLayout.java

void scrollToTab(int tabIndex, int positionOffset) {
    final int tabStripChildCount = mTabStrip.getChildCount();
    if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
        return;//  w w  w  . j a  v a 2 s  .c  o  m
    }

    View selectedChild = mTabStrip.getChildAt(tabIndex);
    if (selectedChild != null) {
        int targetScrollX = selectedChild.getLeft() + positionOffset;

        if (tabIndex > 0 || positionOffset > 0) {
            // If we're not at the first child and are mid-scroll, make sure we obey the offset
            targetScrollX -= mTitleOffset;
        }

        scrollTo(targetScrollX, 0);
    }
}

From source file:com.b44t.ui.Components.PagerSlidingTabStrip.java

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

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

    final int height = getHeight();

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

    // 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 indicator line
    rectPaint.setColor(indicatorColor);
    canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
}

From source file:com.byds.kd.views.SlidingTabLayout.java

private void scrollToTab(int tabIndex, int positionOffset) {
    final int tabStripChildCount = mTabStrip.getChildCount();
    if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
        return;//from w  w  w.  j a va  2 s. c om
    }

    View selectedChild = mTabStrip.getChildAt(tabIndex);
    if (selectedChild != null) {
        int targetScrollX = selectedChild.getLeft() + positionOffset;

        if (tabIndex > 0 || positionOffset > 0) {
            // If we're not at the first child and are mid-scroll, make sure we obey
            // the offset
            targetScrollX -= mTitleOffset;
        }

        scrollTo(targetScrollX, 0);
    }
}

From source file:com.alex.view.tab.TabLayout.java

/**
 * ? onPageScrolled ???/*ww w .  j  av a2  s .c  o  m*/
 */
public void scrollIndicatorTo(int position, float positionOffset) {
    View tabView = getChildAt(position);
    View currentView = getChildAt(mCurrentTab);

    // ?
    mIndicatorAnimOffset = tabView.getLeft() + (int) ((tabView.getWidth() - mIndicatorWidth) / 2)
            + (int) (tabView.getWidth() * positionOffset) - currentView.getLeft()
            - (int) ((currentView.getWidth() - mIndicatorWidth) / 2);

    if (!mTabClickTrigger) {
        mValueAnimator.setInterpolator(null);
        mValueAnimator.setDuration(250);
    }

    invalidate();
}

From source file:com.android.widget.SlidingTabLayout.java

private void scrollToTab(int tabIndex, int positionOffset) {
    final int tabStripChildCount = mTabStrip.getChildCount();
    if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
        return;// w ww  .  j  a  v  a2s  .  c  o m
    }
    View selectedChild = mTabStrip.getChildAt(tabIndex);
    if (selectedChild != null) {
        int targetScrollX = selectedChild.getLeft() + positionOffset;
        if (tabIndex > 0 || positionOffset > 0) {
            // If we're not at the first child and are mid-scroll, make sure we obey the offset
            targetScrollX -= mTitleOffset;
        }
        scrollTo(targetScrollX, 0);
    }
}

From source file:ca.ualberta.cs.swapmyride.View.SlidingTabLayout.java

public void scrollToTab(int tabIndex, int positionOffset) {
    final int tabStripChildCount = mTabStrip.getChildCount();
    if (tabStripChildCount == 0 || tabIndex < 0 || tabIndex >= tabStripChildCount) {
        return;/*from  www .j av  a  2s .  co  m*/
    }

    View selectedChild = mTabStrip.getChildAt(tabIndex);
    if (selectedChild != null) {
        int targetScrollX = selectedChild.getLeft() + positionOffset;

        if (tabIndex > 0 || positionOffset > 0) {
            // If we're not at the first child and are mid-scroll, make sure we obey the offset
            targetScrollX -= mTitleOffset;
        }

        scrollTo(targetScrollX, 0);
    }
}

From source file:com.alex.view.tab.TabLayout.java

@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
    View currentTabView = getChildAt(mCurrentTab);
    IndicatorPoint p = (IndicatorPoint) valueAnimator.getAnimatedValue();
    mIndicatorAnimOffset = (int) p.left - currentTabView.getLeft();
    invalidate();//  w  w  w  . j  av a2  s. c o  m
}