State of Compose 2023 results are in! Click here to learn more

← Back to Foundation

LazyLayout

Component
in
Foundation
. Since 1.2.0

Overview

Code Examples

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

@param itemProvider provides all the needed info about the items which could be used to compose and measure items as part of measurePolicy. @param modifier to apply on the layout @param prefetchState allows to schedule items for prefetching @param measurePolicy Measure policy which allows to only compose and measure needed items.

Overloads

LazyLayout

@Deprecated(
    message = "Use an overload accepting a lambda prodicing an item provider instead",
    replaceWith = ReplaceWith(
        "LazyLayout({ itemProvider }, modifier, prefetchState, measurePolicy)"
    )
)
@ExperimentalFoundationApi
@Composable
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

LazyLayout

@ExperimentalFoundationApi
@Composable
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. Note: this function is a part of LazyLayout harness that allows for building custom lazy layouts. LazyLayout and all corresponding APIs are still under development and are subject to change