New Compose Multiplatform components arrived on Composables UICheck it out →

LazyLayout

A layout that only composes and lays out currently needed items. Can be used to build efficient scrollable layouts.

Last updated:

Installation

dependencies {
   implementation("androidx.compose.foundation:foundation:1.7.0-beta03")
}

Overloads

@Composable
@ExperimentalFoundationApi
@Deprecated(
    message = "Use an overload accepting a lambda prodicing an item provider instead",
    replaceWith = ReplaceWith(
        "LazyLayout({ itemProvider }, modifier, prefetchState, measurePolicy)"
    )

fun LazyLayout(
    itemProvider: LazyLayoutItemProvider,
    modifier: Modifier = Modifier,
    prefetchState: LazyLayoutPrefetchState? = null,
    measurePolicy: LazyLayoutMeasureScope.(Constraints) -> MeasureResult
)

Parameters

namedescription
itemProviderprovides all the needed info about the items which could be used to compose and measure items as part of [measurePolicy].
modifierto apply on the layout
prefetchStateallows to schedule items for prefetching
measurePolicyMeasure policy which allows to only compose and measure needed items.
@Composable
@ExperimentalFoundationApi
fun LazyLayout(
    itemProvider: () -> LazyLayoutItemProvider,
    modifier: Modifier = Modifier,
    prefetchState: LazyLayoutPrefetchState? = null,
    measurePolicy: LazyLayoutMeasureScope.(Constraints) -> MeasureResult
)

Parameters

namedescription
itemProviderlambda producing an item provider containing all the needed info about the items which could be used to compose and measure items as part of [measurePolicy].
modifierto apply on the layout
prefetchStateallows to schedule items for prefetching
measurePolicyMeasure policy which allows to only compose and measure needed items.