LayoutFunction

Positions the children of a container.

Yoga can express a row and a column. It cannot express a pager, where each page sits at a stride the container computes; or a split pane, where a divider the user drags decides the sizes; or a collapsing header, where one child's position depends on another's scroll offset. A layout function is how a container says where its children go.

Children remain part of the parent's Litho tree. They are not a nested tree, so incremental mount, visibility and state all continue to work across them without the container forwarding anything by hand.

Sealed, so the only implementations are the arity shapes below. A container picks one by how many parameters its lambda declares, and the constructor it matches says how many children it may name, so handing a two-child function to a three-child container fails to compile.

The intrinsic-size questions all have answers here, each of which runs the layout function and reads the size back. Override one when the container knows its answer more cheaply — a pager is one page wide however many pages it holds — which needs an object rather than a lambda. An override receives the real children, and an IntrinsicMeasureScope, which cannot measure them.

Inheritors

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(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.