setScrollPosition

open fun setScrollPosition(position: Int, positionOffset: Float, updateSelectedTabView: Boolean)

Set the scroll position of the TabLayout.

Parameters

position

Position of the tab to scroll.

positionOffset

Value from [0, 1) indicating the offset from position.

updateSelectedTabView

Whether to draw the tab at the specified position + positionOffset as selected.

Note that calling the method with updateSelectedTabView = truedoes not select a tab at the specified position, but only draws it as selected. This can be useful for when the TabLayout behavior needs to be linked to another view, such as androidx.viewpager.widget.ViewPager.

See also


open fun setScrollPosition(position: Int, positionOffset: Float, updateSelectedTabView: Boolean, updateIndicatorPosition: Boolean)

Set the scroll position of the TabLayout.

Parameters

position

Position of the tab to scroll.

positionOffset

Value from [0, 1) indicating the offset from position.

updateSelectedTabView

Whether to draw the tab at the specified position + positionOffset as selected.

Note that calling the method with updateSelectedTabView = truedoes not select a tab at the specified position, but only draws it as selected. This can be useful for when the TabLayout behavior needs to be linked to another view, such as androidx.viewpager.widget.ViewPager.

updateIndicatorPosition

Whether to set the indicator to the specified position and offset.

Note that calling the method with updateIndicatorPosition = truedoes not select a tab at the specified position, but only updates the indicator position. This can be useful for when the TabLayout behavior needs to be linked to another view, such as androidx.viewpager.widget.ViewPager.

See also