← Back to Compose UI
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.
@Suppress("ComposableLambdaParameterPosition") @ExperimentalComposeUiApi @UiComposable @Composable fun LookaheadLayout( content: @Composable @UiComposable LookaheadLayoutScope.() -> Unit, modifier: Modifier = Modifier, measurePolicy: MeasurePolicy )
|The children composable to be laid out.|
|Modifiers to be applied to the layout.|
|The policy defining the measurement and positioning of the layout|