HorizontalPager

@Composable()
fun HorizontalPager(count: Int, modifier: Modifier = Modifier, state: PagerState = rememberPagerState(), reverseLayout: Boolean = false, itemSpacing: Dp = 0.dp, contentPadding: PaddingValues = PaddingValues(0.dp), verticalAlignment: Alignment.Vertical = Alignment.CenterVertically, flingBehavior: FlingBehavior = PagerDefaults.flingBehavior( state = state, endContentPadding = contentPadding.calculateEndPadding(LayoutDirection.Ltr), ), key: (page: Int) -> Any? = null, userScrollEnabled: Boolean = true, content: @Composable() PagerScope.(page: Int) -> Unit)

A horizontally scrolling layout that allows users to flip between items to the left and right.

Samples

com.google.accompanist.sample.pager.HorizontalPagerSample

Parameters

count

the number of pages.

modifier

the modifier to apply to this layout.

state

the state object to be used to control or observe the pager's state.

reverseLayout

reverse the direction of scrolling and layout, when true items will be composed from the end to the start and PagerState.currentPage == 0 will mean the first item is located at the end.

itemSpacing

horizontal spacing to add between items.

flingBehavior

logic describing fling behavior.

key

the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one.

userScrollEnabled

whether the scrolling via the user gestures or accessibility actions is allowed. You can still scroll programmatically using the state even when it is disabled.

content

a block which describes the content. Inside this block you can reference PagerScope.currentPage and other properties in PagerScope.