Example usage for android.support.v4.view GravityCompat getAbsoluteGravity

List of usage examples for android.support.v4.view GravityCompat getAbsoluteGravity

Introduction

In this page you can find the example usage for android.support.v4.view GravityCompat getAbsoluteGravity.

Prototype

public static int getAbsoluteGravity(int i, int i2) 

Source Link

Usage

From source file:com.aidy.bottomdrawerlayout.BottomDrawerLayout.java

/**
 * Enable or disable interaction with the given drawer.
 * // w ww  .j a v  a2 s  . c  o m
 * <p>
 * This allows the application to restrict the user's ability to open or
 * close the given drawer. DrawerLayout will still respond to calls to
 * {@link #openDrawer(int)}, {@link #closeDrawer(int)} and friends if a
 * drawer is locked.
 * </p>
 * 
 * <p>
 * Locking a drawer open or closed will implicitly open or close that drawer
 * as appropriate.
 * </p>
 * 
 * @param lockMode
 *            The new lock mode for the given drawer. One of
 *            {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED}
 *            or {@link #LOCK_MODE_LOCKED_OPEN}.
 * @param edgeGravity
 *            Gravity.LEFT, RIGHT, START or END. Expresses which drawer to
 *            change the mode for.
 * 
 * @see #LOCK_MODE_UNLOCKED
 * @see #LOCK_MODE_LOCKED_CLOSED
 * @see #LOCK_MODE_LOCKED_OPEN
 */
public void setDrawerLockMode(int lockMode, int edgeGravity) {
    final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
    if (absGravity == Gravity.BOTTOM) {
        mLockModeBottom = lockMode;
    }
    if (lockMode != LOCK_MODE_UNLOCKED) {
        if (absGravity == Gravity.BOTTOM) {
            final ViewDragHelper helper = mBottomDragger;
            helper.cancel();
        }
    }
    switch (lockMode) {
    case LOCK_MODE_LOCKED_OPEN:
        final View toOpen = findDrawerWithGravity(absGravity);
        if (toOpen != null) {
            openDrawer(toOpen);
        }
        break;
    case LOCK_MODE_LOCKED_CLOSED:
        final View toClose = findDrawerWithGravity(absGravity);
        if (toClose != null) {
            closeDrawer(toClose);
        }
        break;
    }
}

From source file:ticwear.design.widget.CollapsingTextHelper.java

private void calculateBaseOffsets() {
    final float currentTextSize = mCurrentTextSize;

    // We then calculate the collapsed text size, using the same logic
    calculateUsingTextSize(mCollapsedTextSize);
    float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mCollapsedDrawY = mCollapsedBounds.bottom;
        break;//from  w  w w  .ja  v  a 2s  .  co  m
    case Gravity.TOP:
        mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent();
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset;
        break;
    }
    switch (collapsedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mCollapsedDrawX = mCollapsedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mCollapsedDrawX = mCollapsedBounds.left;
        break;
    }

    calculateUsingTextSize(mExpandedTextSize);
    width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mExpandedDrawY = mExpandedBounds.bottom;
        break;
    case Gravity.TOP:
        mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent();
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mExpandedDrawY = mExpandedBounds.centerY() + textOffset;
        break;
    }
    switch (expandedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mExpandedDrawX = mExpandedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mExpandedDrawX = mExpandedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mExpandedDrawX = mExpandedBounds.left;
        break;
    }

    // The bounds have changed so we need to clear the texture
    clearTexture();
    // Now reset the text size back to the original
    setInterpolatedTextSize(currentTextSize);
}

From source file:com.aidy.bottomdrawerlayout.AllDrawerLayout.java

/**
 * Set a simple drawable used for the left or right shadow. The drawable
 * provided must have a nonzero intrinsic width.
 * /*from   w w w .  j a v a2 s  . c  o m*/
 * @param shadowDrawable
 *            Shadow drawable to use at the edge of a drawer
 * @param gravity
 *            Which drawer the shadow should apply to
 */
public void setDrawerShadow(Drawable shadowDrawable, int gravity) {
    /*
     * TODO Someone someday might want to set more complex drawables here.
     * They're probably nuts, but we might want to consider registering
     * callbacks, setting states, etc. properly.
     */

    final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this));
    if ((absGravity & Gravity.LEFT) == Gravity.LEFT) {
        mShadowLeft = shadowDrawable;
        invalidate();
    }
    if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) {
        mShadowRight = shadowDrawable;
        invalidate();
    }
    if ((absGravity & Gravity.TOP) == Gravity.TOP) {
        mShadowTop = shadowDrawable;
        invalidate();
    }
    if ((absGravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
        mShadowBottom = shadowDrawable;
        invalidate();
    }
}

From source file:com.amitupadhyay.aboutexample.util.CollapsingTextHelper.java

private void calculateBaseOffsets() {
    // We then calculate the collapsed text size, using the same logic
    mTextPaint.setTextSize(mCollapsedTextSize);
    float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mCollapsedDrawY = mCollapsedBounds.bottom;
        break;/*ww  w .  ja v a 2s .  c  o m*/
    case Gravity.TOP:
        mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent();
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset;
        break;
    }
    switch (collapsedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mCollapsedDrawX = mCollapsedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mCollapsedDrawX = mCollapsedBounds.left;
        break;
    }
    mTextPaint.setTextSize(mExpandedTextSize);
    width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mExpandedDrawY = mExpandedBounds.bottom;
        break;
    case Gravity.TOP:
        mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent();
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mExpandedDrawY = mExpandedBounds.centerY() + textOffset;
        break;
    }
    switch (expandedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mExpandedDrawX = mExpandedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mExpandedDrawX = mExpandedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mExpandedDrawX = mExpandedBounds.left;
        break;
    }
    // The bounds have changed so we need to clear the texture
    clearTexture();
}

From source file:ru.shmakinv.android.material.widget.CollapsingTextHelper.java

@SuppressLint("RtlHardcoded")
private void calculateBaseOffsets() {
    final float currentTextSize = mCurrentTextSize;

    // We then calculate the collapsed text size, using the same logic
    calculateUsingTextSize(mCollapsedTextSize);
    float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mCollapsedDrawY = mCollapsedBounds.bottom;
        break;/*from  ww w . j a v a  2 s  . c o  m*/
    case Gravity.TOP:
        mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent();
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset;
        break;
    }
    switch (collapsedAbsGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mCollapsedDrawX = mCollapsedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mCollapsedDrawX = mCollapsedBounds.left;
        break;
    }

    calculateUsingTextSize(mExpandedTextSize);
    width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mExpandedDrawY = mExpandedBounds.bottom;
        break;
    case Gravity.TOP:
        mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent();
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mExpandedDrawY = mExpandedBounds.centerY() + textOffset;
        break;
    }
    switch (expandedAbsGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mExpandedDrawX = mExpandedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mExpandedDrawX = mExpandedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mExpandedDrawX = mExpandedBounds.left;
        break;
    }

    // The bounds have changed so we need to clear the texture
    clearTexture();
    // Now reset the text size back to the original
    setInterpolatedTextSize(currentTextSize);
}

From source file:com.tr4android.support.extension.widget.CollapsingTextHelper.java

private void calculateBaseOffsets() {
    final float currentTextSize = mCurrentTextSize;

    // We then calculate the collapsed text size, using the same logic
    calculateUsingTextSize(mCollapsedTextSize);
    mCollapsedTextHeight = -mTextPaint.ascent();
    float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mCollapsedDrawY = mCollapsedBounds.bottom - mCollapsedTextOffsetBottom;
        break;//  w w w .  jav a  2  s . co m
    case Gravity.TOP:
        mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent() + mCollapsedTextOffsetTop;
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset - (mCollapsedTextOffsetBottom / 2)
                + (mCollapsedTextOffsetTop / 2);
        break;
    }
    switch (collapsedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mCollapsedDrawX = mCollapsedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mCollapsedDrawX = mCollapsedBounds.left;
        break;
    }

    calculateUsingTextSize(mExpandedTextSize);
    mExpandedTextHeight = -mTextPaint.ascent();
    width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mExpandedDrawY = mExpandedBounds.bottom - mExpandedTextOffsetBottom;
        break;
    case Gravity.TOP:
        mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent() + mExpandedTextOffsetTop;
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mExpandedDrawY = mExpandedBounds.centerY() + textOffset - (mExpandedTextOffsetBottom / 2)
                + (mExpandedTextOffsetTop / 2);
        break;
    }
    switch (expandedAbsGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mExpandedDrawX = mExpandedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mExpandedDrawX = mExpandedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mExpandedDrawX = mExpandedBounds.left;
        break;
    }

    // The bounds have changed so we need to clear the texture
    clearTexture();
    // Now reset the text size back to the original
    setInterpolatedTextSize(currentTextSize);
}

From source file:com.actionbarsherlock.custom.widget.VerticalDrawerLayout.java

/**
 * Enable or disable interaction with the given drawer.
 *
 * <p>This allows the application to restrict the user's ability to open or close
 * the given drawer. VerticalDrawerLayout will still respond to calls to {@link #openDrawer(int)},
 * {@link #closeDrawer(int)} and friends if a drawer is locked.</p>
 *
 * <p>Locking a drawer open or closed will implicitly open or close
 * that drawer as appropriate.</p>
 *
 * @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED},
 *                 {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}.
 * @param edgeGravity Gravity.TOP, BOTTOM, START or END.
 *                    Expresses which drawer to change the mode for.
 *
 * @see #LOCK_MODE_UNLOCKED/*from  ww  w.ja  va2 s .  c om*/
 * @see #LOCK_MODE_LOCKED_CLOSED
 * @see #LOCK_MODE_LOCKED_OPEN
 */
public void setDrawerLockMode(int lockMode, int edgeGravity) {
    final int absGrav = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
    if (absGrav == Gravity.TOP) {
        mLockModeTop = lockMode;
    } else if (absGrav == Gravity.BOTTOM) {
        mLockModeBottom = lockMode;
    }
    if (lockMode != LOCK_MODE_UNLOCKED) {
        // Cancel interaction in progress
        final ViewDragHelper helper = absGrav == Gravity.TOP ? mTopDragger : mBottomDragger;
        helper.cancel();
    }
    switch (lockMode) {
    case LOCK_MODE_LOCKED_OPEN:
        final View toOpen = findDrawerWithGravity(absGrav);
        if (toOpen != null) {
            openDrawer(toOpen);
        }
        break;
    case LOCK_MODE_LOCKED_CLOSED:
        final View toClose = findDrawerWithGravity(absGrav);
        if (toClose != null) {
            closeDrawer(toClose);
        }
        break;
    // default: do nothing
    }
}

From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java

/**
 * Set a simple drawable used for the left or right shadow.
 * The drawable provided must have a nonzero intrinsic width.
 *
 * @param shadowDrawable Shadow drawable to use at the edge of a drawer
 * @param gravity Which drawer the shadow should apply to
 *//* w ww.  j  a v  a 2 s  . c  o m*/
public void setDrawerShadow(Drawable shadowDrawable, @EdgeGravity int gravity) {
    /*
     * TODO Someone someday might want to set more complex drawables here.
     * They're probably nuts, but we might want to consider registering callbacks,
     * setting states, etc. properly.
     */

    final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this));
    if ((absGravity & Gravity.LEFT) == Gravity.LEFT) {
        mShadowLeft = shadowDrawable;
        invalidate();
    }
    if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) {
        mShadowRight = shadowDrawable;
        invalidate();
    }
}

From source file:com.abewy.android.apps.klyph.widget.KlyphDrawerLayout.java

/**
 * Enable or disable interaction with the given drawer.
 *
 * <p>This allows the application to restrict the user's ability to open or close
 * the given drawer. DrawerLayout will still respond to calls to {@link #openDrawer(int)},
 * {@link #closeDrawer(int)} and friends if a drawer is locked.</p>
 *
 * <p>Locking a drawer open or closed will implicitly open or close
 * that drawer as appropriate.</p>
 *
 * @param lockMode The new lock mode for the given drawer. One of {@link #LOCK_MODE_UNLOCKED},
 *                 {@link #LOCK_MODE_LOCKED_CLOSED} or {@link #LOCK_MODE_LOCKED_OPEN}.
 * @param edgeGravity Gravity.LEFT, RIGHT, START or END.
 *                    Expresses which drawer to change the mode for.
 *
 * @see #LOCK_MODE_UNLOCKED//  www  .j a  v a  2s  .c  om
 * @see #LOCK_MODE_LOCKED_CLOSED
 * @see #LOCK_MODE_LOCKED_OPEN
 */
public void setDrawerLockMode(int lockMode, int edgeGravity) {
    final int absGrav = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
    if (absGrav == Gravity.LEFT) {
        mLockModeLeft = lockMode;
    } else if (absGrav == Gravity.RIGHT) {
        mLockModeRight = lockMode;
    }
    if (lockMode != LOCK_MODE_UNLOCKED) {
        // Cancel interaction in progress
        final ViewDragHelper helper = absGrav == Gravity.LEFT ? mLeftDragger : mRightDragger;
        helper.cancel();
    }
    switch (lockMode) {
    case LOCK_MODE_LOCKED_OPEN:
        final View toOpen = findDrawerWithGravity(absGrav);
        if (toOpen != null) {
            openDrawer(toOpen);
        }
        break;
    case LOCK_MODE_LOCKED_CLOSED:
        final View toClose = findDrawerWithGravity(absGrav);
        if (toClose != null) {
            closeDrawer(toClose);
        }
        break;
    // default: do nothing
    }
}

From source file:android.support.design.widget.CollapsingTextHelper.java

private void calculateBaseOffsets() {
    final float currentTextSize = mCurrentTextSize;

    // We then calculate the collapsed text size, using the same logic
    calculateUsingTextSize(mCollapsedTextSize);
    float width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int collapsedAbsGravity = GravityCompat.getAbsoluteGravity(mCollapsedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (collapsedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mCollapsedDrawY = mCollapsedBounds.bottom;
        break;/*from   w ww  . j  a v  a  2s.co  m*/
    case Gravity.TOP:
        mCollapsedDrawY = mCollapsedBounds.top - mTextPaint.ascent();
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mCollapsedDrawY = mCollapsedBounds.centerY() + textOffset;
        break;
    }
    switch (collapsedAbsGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mCollapsedDrawX = mCollapsedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mCollapsedDrawX = mCollapsedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mCollapsedDrawX = mCollapsedBounds.left;
        break;
    }

    calculateUsingTextSize(mExpandedTextSize);
    width = mTextToDraw != null ? mTextPaint.measureText(mTextToDraw, 0, mTextToDraw.length()) : 0;
    final int expandedAbsGravity = GravityCompat.getAbsoluteGravity(mExpandedTextGravity,
            mIsRtl ? ViewCompat.LAYOUT_DIRECTION_RTL : ViewCompat.LAYOUT_DIRECTION_LTR);
    switch (expandedAbsGravity & Gravity.VERTICAL_GRAVITY_MASK) {
    case Gravity.BOTTOM:
        mExpandedDrawY = mExpandedBounds.bottom;
        break;
    case Gravity.TOP:
        mExpandedDrawY = mExpandedBounds.top - mTextPaint.ascent();
        break;
    case Gravity.CENTER_VERTICAL:
    default:
        float textHeight = mTextPaint.descent() - mTextPaint.ascent();
        float textOffset = (textHeight / 2) - mTextPaint.descent();
        mExpandedDrawY = mExpandedBounds.centerY() + textOffset;
        break;
    }
    switch (expandedAbsGravity & GravityCompat.RELATIVE_HORIZONTAL_GRAVITY_MASK) {
    case Gravity.CENTER_HORIZONTAL:
        mExpandedDrawX = mExpandedBounds.centerX() - (width / 2);
        break;
    case Gravity.RIGHT:
        mExpandedDrawX = mExpandedBounds.right - width;
        break;
    case Gravity.LEFT:
    default:
        mExpandedDrawX = mExpandedBounds.left;
        break;
    }

    // The bounds have changed so we need to clear the texture
    clearTexture();
    // Now reset the text size back to the original
    setInterpolatedTextSize(currentTextSize);
}