Most visited

Recently visited

PagerTabStrip

public class PagerTabStrip
extends PagerTitleStrip

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.support.v4.view.PagerTitleStrip
         ↳ android.support.v4.view.PagerTabStrip


PagerTabStrip is an 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 a non-interactive indicator, see PagerTitleStrip.

Summary

Inherited XML attributes

From class android.view.ViewGroup
From class android.view.View

Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

PagerTabStrip(Context context)
PagerTabStrip(Context context, AttributeSet attrs)

Public methods

boolean getDrawFullUnderline()

Return whether or not this tab strip will draw a full-width underline.

int getTabIndicatorColor()
boolean onTouchEvent(MotionEvent ev)

Implement this method to handle touch screen motion events.

void setBackgroundColor(int color)

Sets the background color for this view.

void setBackgroundDrawable(Drawable d)

This method is deprecated. use setBackground(Drawable) instead

void setBackgroundResource(int resId)

Set the background to a given resource.

void setDrawFullUnderline(boolean drawFull)

Set whether this tab strip should draw a full-width underline in the current tab indicator color.

void setPadding(int left, int top, int right, int bottom)

Sets the padding.

void setTabIndicatorColor(int color)

Set the color of the tab indicator bar.

void setTabIndicatorColorResource(int resId)

Set the color of the tab indicator bar from a color resource.

void setTextSpacing(int textSpacing)

Set the required spacing between title segments.

Protected methods

void onDraw(Canvas canvas)

Implement this to do your drawing.

Inherited methods

From class android.support.v4.view.PagerTitleStrip
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

PagerTabStrip

PagerTabStrip (Context context)

Parameters
context Context

PagerTabStrip

PagerTabStrip (Context context, 
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

Public methods

getDrawFullUnderline

boolean getDrawFullUnderline ()

Return whether or not this tab strip will draw a full-width underline. This defaults to true if no background is set.

Returns
boolean true if this tab strip will draw a full-width underline in the current tab indicator color.

getTabIndicatorColor

int getTabIndicatorColor ()

Returns
int The current tab indicator color as an 0xRRGGBB value.

onTouchEvent

boolean onTouchEvent (MotionEvent ev)

Implement this method to handle touch screen motion events.

If this method is used to detect click actions, it is recommended that the actions be performed by implementing and calling performClick(). This will ensure consistent system behavior, including:

  • obeying click sound preferences
  • dispatching OnClickListener calls
  • handling ACTION_CLICK when accessibility features are enabled

Parameters
ev MotionEvent: The motion event.
Returns
boolean True if the event was handled, false otherwise.

setBackgroundColor

void setBackgroundColor (int color)

Sets the background color for this view.

Parameters
color int: the color of the background

setBackgroundDrawable

void setBackgroundDrawable (Drawable d)

This method is deprecated.
use setBackground(Drawable) instead

Parameters
d Drawable

setBackgroundResource

void setBackgroundResource (int resId)

Set the background to a given resource. The resource should refer to a Drawable object or 0 to remove the background.

Parameters
resId int: The identifier of the resource.

setDrawFullUnderline

void setDrawFullUnderline (boolean drawFull)

Set whether this tab strip should draw a full-width underline in the current tab indicator color.

Parameters
drawFull boolean: true to draw a full-width underline, false otherwise

setPadding

void setPadding (int left, 
                int top, 
                int right, 
                int bottom)

Sets the padding. The view may add on the space required to display the scrollbars, depending on the style and visibility of the scrollbars. So the values returned from getPaddingLeft(), getPaddingTop(), getPaddingRight() and getPaddingBottom() may be different from the values set in this call.

Parameters
left int: the left padding in pixels
top int: the top padding in pixels
right int: the right padding in pixels
bottom int: the bottom padding in pixels

setTabIndicatorColor

void setTabIndicatorColor (int color)

Set the color of the tab indicator bar.

Parameters
color int: Color to set as an 0xRRGGBB value. The high byte (alpha) is ignored.

setTabIndicatorColorResource

void setTabIndicatorColorResource (int resId)

Set the color of the tab indicator bar from a color resource.

Parameters
resId int: Resource ID of a color resource to load

setTextSpacing

void setTextSpacing (int textSpacing)

Set the required spacing between title segments.

Parameters
textSpacing int: Spacing between each title displayed in pixels

Protected methods

onDraw

void onDraw (Canvas canvas)

Implement this to do your drawing.

Parameters
canvas Canvas: the canvas on which the background will be drawn

Hooray!