androidx.compose.foundation.lazy.layout

LazyLayout

Composable function · from org.jetbrains.compose.foundation:foundation:1.12.2

LazyLayout is what LazyColumn, LazyVerticalGrid and HorizontalPager are built on. It creates only the items that are needed, and you decide where each one goes.

You need it only for a scrolling arrangement that none of the lazy lists, grids and pagers can do, like a calendar with items positioned by time, or items on a circle. You handle scrolling yourself.

The parts:

The API is low level and may still change.

Read more

Parameters

@Composable
fun LazyLayout(
    itemProvider: () -> LazyLayoutItemProvider,
    modifier: Modifier = Modifier,
    prefetchState: LazyLayoutPrefetchState? = null,
    measurePolicy: LazyLayoutMeasurePolicy,
)

itemProvider: () -> LazyLayoutItemProviderRequired

Returns the provider of the items: the count, and the content of each item by index.

modifier: ModifierOptional

Default: Modifier

Changes size, padding, or position. Add scrolling here, for example with Modifier.scrollable.

prefetchState: LazyLayoutPrefetchState?Optional

Default: null

Lets you create items in advance, before they become visible.

measurePolicy: LazyLayoutMeasurePolicyRequired

Decides which items to measure and where to place them. Gets the constraints; measure an item with compose(index) and measure.