@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
    final int heightMode = MeasureSpec.getMode(heightMeasureSpec);
    final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    final int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    if (widthMode != MeasureSpec.EXACTLY) {
      throw new IllegalStateException("Must measure with an exact width");
    }

    int childHeight = heightSize;
    int minHeight = getMinHeight();
    int padding = 0;
    padding = getPaddingTop() + getPaddingBottom();
    childHeight -= padding;

    final int childWidthSpec =
        MeasureSpec.makeMeasureSpec((int) (widthSize * 0.8f), MeasureSpec.AT_MOST);
    final int childHeightSpec = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.AT_MOST);

    mPrevText.measure(childWidthSpec, childHeightSpec);
    mCurrText.measure(childWidthSpec, childHeightSpec);
    mNextText.measure(childWidthSpec, childHeightSpec);

    if (heightMode == MeasureSpec.EXACTLY) {
      setMeasuredDimension(widthSize, heightSize);
    } else {
      int textHeight = mCurrText.getMeasuredHeight();
      setMeasuredDimension(widthSize, Math.max(minHeight, textHeight + padding));
    }
  }
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