by @alexstyl
✉️ Leave your feedback

← Back to Compose UI


Compose UI
. Since 1.3.0



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.



fun LookaheadLayout(
    content: @Composable @UiComposable LookaheadLayoutScope.() -> Unit,
    modifier: Modifier = Modifier,
    measurePolicy: MeasurePolicy


contentThe children composable to be laid out.
modifierModifiers to be applied to the layout.
measurePolicyThe policy defining the measurement and positioning of the layout
Previous ComponentLayout
Next ComponentLookaheadScope