PagerTitleStrip

open class PagerTitleStrip : ViewGroup
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ androidx.viewpager.widget.PagerTitleStrip

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 PagerAdapter#getPageTitle(int) in the adapter supplied to the ViewPager.

For an interactive indicator, see PagerTabStrip.

Summary

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

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

Public methods
open Unit

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

open Unit
setTextSpacing(spacingPixels: Int)

Set the required spacing between title segments.

open Unit
setGravity(gravity: Int)

Set the Gravity used to position text within the title strip.

open Unit
setTextSize(unit: Int, size: Float)

Set the default text size to a given unit and value.

open Unit
setTextColor(color: Int)

Set the color value used as the base color for all displayed page titles.

open Int

open Unit

Protected methods
open Unit

open Unit

open Unit
onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int)

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

Public constructors

<init>

PagerTitleStrip(@NonNull context: Context)

<init>

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

Public methods

setNonPrimaryAlpha

open fun setNonPrimaryAlpha(alpha: Float): Unit

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

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

setTextSpacing

open fun setTextSpacing(spacingPixels: Int): Unit

Set the required spacing between title segments.

Parameters
spacingPixels Int: Spacing between each title displayed in pixels

setGravity

open fun setGravity(gravity: Int): Unit

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

setTextSize

open fun setTextSize(unit: Int, size: Float): Unit

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 Int: The desired size in the given units

setTextColor

open fun setTextColor(color: Int): Unit

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

getTextSpacing

open fun getTextSpacing(): Int
Return
Int: The required spacing between title segments in pixels

requestLayout

open fun requestLayout(): Unit

Protected methods

onAttachedToWindow

protected open fun onAttachedToWindow(): Unit

onDetachedFromWindow

protected open fun onDetachedFromWindow(): Unit

onLayout

protected open fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int): Unit

onMeasure

protected open fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int): Unit