Compose Component

GlimmerHorizontalPager

GlimmerHorizontalPager is a lazily-composed, horizontally scrollable layout that arranges its pages sequentially.

GlimmerHorizontalPager

Source set: Android
@Composable
public fun GlimmerHorizontalPager(
    state: GlimmerPagerState,
    modifier: Modifier = Modifier,
    contentPadding: PaddingValues = PaddingValues(0.dp),
    beyondViewportPageCount: Int = 0,
    pageSpacing: Dp = 0.dp,
    verticalAlignment: Alignment.Vertical = Alignment.Bottom,
    userScrollEnabled: Boolean = true,
    reverseLayout: Boolean = false,
    key: ((page: Int) -> Any)? = null,
    pageContent: @Composable GlimmerPagerScope.(page: Int) -> Unit,
)

Parameters

state the state object to be used to control or observe the pager's state.
modifier the modifier to apply to this layout.
contentPadding a padding around the whole content. This will add padding for the content after it has been clipped, which is not possible via modifier param. You can use it to add a padding before the first page or after the last one. Use pageSpacing to add spacing between the pages.
beyondViewportPageCount Pages to compose and layout before and after the list of visible pages. Note: Be aware that using a large value for beyondViewportPageCount will cause a lot of pages to be composed, measured and placed which will defeat the purpose of using lazy loading. This should be used as an optimization to pre-load a couple of pages before and after the visible ones. This does not include the pages automatically composed and laid out by the pre-fetcher in the direction of the scroll during scroll events.
pageSpacing The amount of space to be used to separate the pages in this Pager
verticalAlignment how pages are aligned vertically within the pager's viewport.
userScrollEnabled whether the scrolling via the user gestures or accessibility actions is allowed. You can still scroll programmatically using GlimmerPagerState.scroll even when it is disabled.
reverseLayout reverse the direction of scrolling and layout.
key a stable and unique key representing the item. When specified, the scroll position will be maintained based on the key. If null, the position in the pager will represent the key.
pageContent a block that describes the content of a single page.

Last updated: