PagerState
Class
Android
public class PagerState(
@IntRange(from = 0) currentPage: Int = 0,
@FloatRange(from = -0.5, to = 0.5) currentPageOffsetFraction: Float = 0f,
@IntRange(from = 1) pageCount: () -> Int,
) : ScrollableState
The state that can be used in conjunction with Wear HorizontalPager and VerticalPager.
Parameters
| currentPage | The index of the current active page. |
| currentPageOffsetFraction | The fractional offset from the start of the current page. Should be between -0.5 and 0.5, where 0 indicates the start of the initial page. |
| pageCount | The number of pages in this Pager. |
Functions
public suspend fun scrollToPage(
page: Int,
@FloatRange(from = -0.5, to = 0.5) pageOffsetFraction: Float = 0f,
): Unit
Scroll (jump immediately) to a given page.
Parameters
| page | The destination page to scroll to |
| pageOffsetFraction | A fraction of the page size that indicates the offset the destination page will be offset from its snapped position. |
public suspend fun animateScrollToPage(
page: Int,
@FloatRange(from = -0.5, to = 0.5) pageOffsetFraction: Float = 0f,
animationSpec: AnimationSpec<Float> = spring(),
)
Scroll animate to a given page. If the page is too far away from currentPage we will
not compose all pages in the way. We will pre-jump to a nearer page, compose and animate the
rest of the pages until page.
Parameters
| page | The destination page to scroll to |
| pageOffsetFraction | A fraction of the page size that indicates the offset the destination page will be offset from its snapped position. |
| animationSpec | An AnimationSpec to move between pages. We'll use a spring as the default animation. |
Companion Object
Properties
Android
public val Saver: Saver<PagerState, *>
To keep current page and page offset saved
