belongs to Maven artifact androidx.viewpager:viewpager:1.0.0-alpha1

PagerTabStrip

public class PagerTabStrip
extends PagerTitleStrip

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ androidx.viewpager.widget.PagerTitleStrip
         ↳ androidx.viewpager.widget.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 PagerAdapter.getPageTitle(int) in the adapter supplied to the ViewPager.

For a non-interactive indicator, see PagerTitleStrip.

Summary

Inherited constants

Inherited fields

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)
void setBackgroundColor(int color)
void setBackgroundDrawable(Drawable d)
void setBackgroundResource(int resId)
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)
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)

Inherited methods

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)

Parameters
ev MotionEvent

Returns
boolean

setBackgroundColor

void setBackgroundColor (int color)

Parameters
color int

setBackgroundDrawable

void setBackgroundDrawable (Drawable d)

Parameters
d Drawable

setBackgroundResource

void setBackgroundResource (int resId)

Parameters
resId int

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)

Parameters
left int

top int

right int

bottom int

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)

Parameters
canvas Canvas