🌈 Create new beautiful Compose Gradients with our new wesite ->
Composable Function

SubcomposeLayout

Analogue of Layout which allows to subcompose the actual content during the measuring stage for example to use the values calculated during the measurement as params for the composition of the children.

SubcomposeLayout

Source set: Common
@Composable
public fun SubcomposeLayout(
    modifier: Modifier = Modifier,
    measurePolicy: SubcomposeMeasureScope.(Constraints) -> MeasureResult,
)

Analogue of Layout which allows to subcompose the actual content during the measuring stage for example to use the values calculated during the measurement as params for the composition of the children.

Possible use cases:

    your use case with just custom Layout or LayoutModifier. See androidx.compose.foundation.layout.BoxWithConstraints.

  • You need to know the constraints passed by the parent during the composition and can't solve
  • You want to use the size of one child during the composition of the second child.
  • of 100 items and instead of composing all of them you only compose the ones which are currently visible(say 5 of them) and compose next items when the component is scrolled.

  • You want to compose your items lazily based on the available size. For example you have a list

Parameters

modifier Modifier to apply for the layout.
measurePolicy Measure policy which provides ability to subcompose during the measuring.

SubcomposeLayout

Source set: Common
@Composable
public fun SubcomposeLayout(
    state: SubcomposeLayoutState,
    modifier: Modifier = Modifier,
    measurePolicy: SubcomposeMeasureScope.(Constraints) -> MeasureResult,
)

Analogue of Layout which allows to subcompose the actual content during the measuring stage for example to use the values calculated during the measurement as params for the composition of the children.

Possible use cases:

    your use case with just custom Layout or LayoutModifier. See androidx.compose.foundation.layout.BoxWithConstraints.

  • You need to know the constraints passed by the parent during the composition and can't solve
  • You want to use the size of one child during the composition of the second child.
  • of 100 items and instead of composing all of them you only compose the ones which are currently visible(say 5 of them) and compose next items when the component is scrolled.

  • You want to compose your items lazily based on the available size. For example you have a list

Parameters

state the state object to be used by the layout.
modifier Modifier to apply for the layout.
measurePolicy Measure policy which provides ability to subcompose during the measuring.