void updateTextPositions(int position, float positionOffset, boolean force) {
    if (position != mLastKnownCurrentPage) {
      updateText(position, mPager.getAdapter());
    } else if (!force && positionOffset == mLastKnownPositionOffset) {
      return;
    }

    mUpdatingPositions = true;

    final int prevWidth = mPrevText.getMeasuredWidth();
    final int currWidth = mCurrText.getMeasuredWidth();
    final int nextWidth = mNextText.getMeasuredWidth();
    final int halfCurrWidth = currWidth / 2;

    final int stripWidth = getWidth();
    final int stripHeight = getHeight();
    final int paddingLeft = getPaddingLeft();
    final int paddingRight = getPaddingRight();
    final int paddingTop = getPaddingTop();
    final int paddingBottom = getPaddingBottom();
    final int textPaddedLeft = paddingLeft + halfCurrWidth;
    final int textPaddedRight = paddingRight + halfCurrWidth;
    final int contentWidth = stripWidth - textPaddedLeft - textPaddedRight;

    float currOffset = positionOffset + 0.5f;
    if (currOffset > 1.f) {
      currOffset -= 1.f;
    }
    final int currCenter = stripWidth - textPaddedRight - (int) (contentWidth * currOffset);
    final int currLeft = currCenter - currWidth / 2;
    final int currRight = currLeft + currWidth;

    final int prevBaseline = mPrevText.getBaseline();
    final int currBaseline = mCurrText.getBaseline();
    final int nextBaseline = mNextText.getBaseline();
    final int maxBaseline = Math.max(Math.max(prevBaseline, currBaseline), nextBaseline);
    final int prevTopOffset = maxBaseline - prevBaseline;
    final int currTopOffset = maxBaseline - currBaseline;
    final int nextTopOffset = maxBaseline - nextBaseline;
    final int alignedPrevHeight = prevTopOffset + mPrevText.getMeasuredHeight();
    final int alignedCurrHeight = currTopOffset + mCurrText.getMeasuredHeight();
    final int alignedNextHeight = nextTopOffset + mNextText.getMeasuredHeight();
    final int maxTextHeight =
        Math.max(Math.max(alignedPrevHeight, alignedCurrHeight), alignedNextHeight);

    final int vgrav = mGravity & Gravity.VERTICAL_GRAVITY_MASK;

    int prevTop;
    int currTop;
    int nextTop;
    switch (vgrav) {
      default:
      case Gravity.TOP:
        prevTop = paddingTop + prevTopOffset;
        currTop = paddingTop + currTopOffset;
        nextTop = paddingTop + nextTopOffset;
        break;
      case Gravity.CENTER_VERTICAL:
        final int paddedHeight = stripHeight - paddingTop - paddingBottom;
        final int centeredTop = (paddedHeight - maxTextHeight) / 2;
        prevTop = centeredTop + prevTopOffset;
        currTop = centeredTop + currTopOffset;
        nextTop = centeredTop + nextTopOffset;
        break;
      case Gravity.BOTTOM:
        final int bottomGravTop = stripHeight - paddingBottom - maxTextHeight;
        prevTop = bottomGravTop + prevTopOffset;
        currTop = bottomGravTop + currTopOffset;
        nextTop = bottomGravTop + nextTopOffset;
        break;
    }

    mCurrText.layout(currLeft, currTop, currRight, currTop + mCurrText.getMeasuredHeight());

    final int prevLeft = Math.min(paddingLeft, currLeft - mScaledTextSpacing - prevWidth);
    mPrevText.layout(prevLeft, prevTop, prevLeft + prevWidth,
        prevTop + mPrevText.getMeasuredHeight());

    final int nextLeft =
        Math.max(stripWidth - paddingRight - nextWidth, currRight + mScaledTextSpacing);
    mNextText.layout(nextLeft, nextTop, nextLeft + nextWidth,
        nextTop + mNextText.getMeasuredHeight());

    mLastKnownPositionOffset = positionOffset;
    mUpdatingPositions = false;
  }
Set the {@link Gravity} used to position text within the title strip.
Only the vertical gravity component is used.

@param gravity {@link Gravity} constant for positioning title text
sample/src/main/java/android/support/v4/view/PagerTitleStripV22.java