← Back to Compose UI
LookaheadLayout
Overview
Examples
Community Notes
LookaheadLayout is a Layout that runs a lookahead measure and placement pass to determine the layout. Immediately afterwards, another measure and placement pass will begin, in which the measurement and placement of any layout can be adjusted based on the lookahead results via LookaheadLayoutScope.intermediateLayout.
During the lookahead pass, the layout adjustment logic defined in LookaheadLayoutScope.intermediateLayout will be skipped, so that any transient morphing of the layout is not taken into account when predetermining the target layout.
Once the lookahead is finished, another measure & layout pass will begin. LookaheadLayoutScope.intermediateLayout can be used to create an intermediate layout based on incoming constraints and the lookahead results. This can result in layouts that gradually change their sizes & positions towards the target layout calculated by the lookahead.
Caveat: SubcomposeLayout is not yet supported in LookaheadLayout. It will be supported in an upcoming release.
Overloads
LookaheadLayout
@Suppress("ComposableLambdaParameterPosition")
@ExperimentalComposeUiApi
@UiComposable
@Composable
fun LookaheadLayout(
content: @Composable @UiComposable LookaheadLayoutScope.() -> Unit,
modifier: Modifier = Modifier,
measurePolicy: MeasurePolicy
)
Parameters
Name | Description |
---|---|
content | The children composable to be laid out. |
modifier | Modifiers to be applied to the layout. |
measurePolicy | The policy defining the measurement and positioning of the layout |