@Override protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    final ViewParent parent = getParent();
    if (!(parent instanceof ViewPager)) {
      throw new IllegalStateException("PagerTitleStrip must be a direct child of a ViewPager.");
    }

    final ViewPager pager = (ViewPager) parent;
    final PagerAdapter adapter = pager.getAdapter();

    pager.setInternalPageChangeListener(mPageListener);
    pager.setOnAdapterChangeListener(mPageListener);
    mPager = pager;
    updateAdapter(mWatchingAdapter != null ? mWatchingAdapter.get() : null, adapter);
  }
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