Android APIs
public class

PagerTitleStrip

extends ViewGroup
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.support.v4.view.PagerTitleStrip
Known Direct Subclasses

Class Overview

PagerTitleStrip is a non-interactive indicator of the current, next, and previous pages of a ViewPager. It is intended to be used as a child view of a ViewPager widget in your XML layout. Add it as a child of a ViewPager in your layout file and set its android:layout_gravity to TOP or BOTTOM to pin it to the top or bottom of the ViewPager. The title from each page is supplied by the method getPageTitle(int) in the adapter supplied to the ViewPager.

For an interactive indicator, see PagerTabStrip.

Summary

[Expand]
Inherited XML Attributes
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
PagerTitleStrip(Context context)
PagerTitleStrip(Context context, AttributeSet attrs)
Public Methods
int getTextSpacing()
void requestLayout()
Call this when something has changed which has invalidated the layout of this view.
void setGravity(int gravity)
Set the Gravity used to position text within the title strip.
void setNonPrimaryAlpha(float alpha)
Set the alpha value used for non-primary page titles.
void setTextColor(int color)
Set the color value used as the base color for all displayed page titles.
void setTextSize(int unit, float size)
Set the default text size to a given unit and value.
void setTextSpacing(int spacingPixels)
Set the required spacing between title segments.
Protected Methods
void onAttachedToWindow()
This is called when the view is attached to a window.
void onDetachedFromWindow()
This is called when the view is detached from a window.
void onLayout(boolean changed, int l, int t, int r, int b)
Called from layout when this view should assign a size and position to each of its children.
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

[Expand]
Inherited Methods
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public PagerTitleStrip (Context context)

Parameters
context Context

public PagerTitleStrip (Context context, AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

Public Methods

public int getTextSpacing ()

Returns
int The required spacing between title segments in pixels

public void requestLayout ()

Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree. This should not be called while the view hierarchy is currently in a layout pass (isInLayout(). If layout is happening, the request may be honored at the end of the current layout pass (and then layout will run again) or after the current frame is drawn and the next layout occurs.

Subclasses which override this method should call the superclass method to handle possible request-during-layout errors correctly.

public void setGravity (int gravity)

Set the Gravity used to position text within the title strip. Only the vertical gravity component is used.

Parameters
gravity int: Gravity constant for positioning title text

public void setNonPrimaryAlpha (float alpha)

Set the alpha value used for non-primary page titles.

Parameters
alpha float: Opacity value in the range 0-1f

public void setTextColor (int color)

Set the color value used as the base color for all displayed page titles. Alpha will be ignored for non-primary page titles. See setNonPrimaryAlpha(float).

Parameters
color int: Color hex code in 0xAARRGGBB format

public void setTextSize (int unit, float size)

Set the default text size to a given unit and value. See TypedValue for the possible dimension units.

Example: to set the text size to 14px, use setTextSize(TypedValue.COMPLEX_UNIT_PX, 14);

Parameters
unit int: The desired dimension unit
size float: The desired size in the given units

public void setTextSpacing (int spacingPixels)

Set the required spacing between title segments.

Parameters
spacingPixels int: Spacing between each title displayed in pixels

Protected Methods

protected void onAttachedToWindow ()

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).

protected void onDetachedFromWindow ()

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.

protected void onLayout (boolean changed, int l, int t, int r, int b)

Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.

Parameters
changed boolean: This is a new size or position for this view
l int: Left position, relative to parent
t int: Top position, relative to parent
r int: Right position, relative to parent
b int: Bottom position, relative to parent

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec int: horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec int: vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.