LayoutFunction1

A layout function for a container with exactly one child, which it receives by name.

Layout(icon) { child, c ->
val placeable = child.measure(c)
layout(c.maxWidth, placeable.height) {
placeable.place(x = (c.maxWidth - placeable.width) / 2, y = 0)
}
}

Naming the children beats indexing a list for them: measurables[0] is a lookup that can be wrong, child cannot be.

Functions

Link copied to clipboard

The tallest this container would like to be at width, ignoring any upper bound.

Link copied to clipboard
open fun IntrinsicMeasureScope.maxIntrinsicWidth(measurables: List<Measurable>, height: Int): Int

The widest this container would like to be at height, ignoring any upper bound.

Link copied to clipboard
abstract fun MeasureScope.measure(child: Measurable, constraints: SizeConstraints)

open override fun MeasureScope.measure(measurables: List<Measurable>, constraints: SizeConstraints)

Measure the children, then say how big this container is and where each child goes.

Link copied to clipboard

The shortest this container can be at width. The other axis of minIntrinsicWidth.

Link copied to clipboard
open fun IntrinsicMeasureScope.minIntrinsicWidth(measurables: List<Measurable>, height: Int): Int

The narrowest this container can be at height without its content breaking out of it.