Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

PagerTabStrip

open class PagerTabStrip : PagerTitleStrip
kotlin.Any
   ↳ 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

Public constructors
<init>(@NonNull context: Context)

<init>(@NonNull context: Context, @Nullable attrs: AttributeSet?)

Public methods
open Boolean

open Unit
setPadding(left: Int, top: Int, right: Int, bottom: Int)

open Unit

Set the color of the tab indicator bar.

open Boolean

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

open Unit
setTextSpacing(textSpacing: Int)

open Unit

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

open Int

open Unit

open Unit
setBackgroundResource(@DrawableRes resId: Int)

open Unit

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

open Unit

Protected methods
open Unit
onDraw(canvas: Canvas!)

Inherited functions

Public constructors

<init>

PagerTabStrip(@NonNull context: Context)

<init>

PagerTabStrip(@NonNull context: Context, @Nullable attrs: AttributeSet?)

Public methods

onTouchEvent

open fun onTouchEvent(ev: MotionEvent!): Boolean

setPadding

open fun setPadding(left: Int, top: Int, right: Int, bottom: Int): Unit

setTabIndicatorColor

open fun setTabIndicatorColor(color: Int): Unit

Set the color of the tab indicator bar.

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

getDrawFullUnderline

open fun getDrawFullUnderline(): Boolean

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

Return
Boolean: true if this tab strip will draw a full-width underline in the current tab indicator color.

setTextSpacing

open fun setTextSpacing(textSpacing: Int): Unit

setDrawFullUnderline

open fun setDrawFullUnderline(drawFull: Boolean): Unit

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

getTabIndicatorColor

open fun getTabIndicatorColor(): Int
Return
Int: The current tab indicator color as an 0xRRGGBB value.

setBackgroundDrawable

open fun setBackgroundDrawable(d: Drawable!): Unit

setBackgroundResource

open fun setBackgroundResource(@DrawableRes resId: Int): Unit

setTabIndicatorColorResource

open fun setTabIndicatorColorResource(@ColorRes resId: Int): Unit

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

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

setBackgroundColor

open fun setBackgroundColor(color: Int): Unit

Protected methods

onDraw

protected open fun onDraw(canvas: Canvas!): Unit