weighted

fun weighted(weight: Float, block: ColumnScope.() -> Unit)

Wraps the children added inside block so that the layout engine gives them a proportional share of the parent container's remaining space along the main axis.

Inside a row, weighted(2f) { ... } widens the wrapped content to (2 / totalWeights) × (rowWidth − fixedWidth). Inside a column it does the same to height. Multiple weighted siblings split the remaining space proportionally — weighted(1f) { ... } next to weighted(2f) { ... } becomes a 1:2 ratio.

The block runs in a ColumnScope so multiple children inside a weighted area stack vertically. Wrap them in row explicitly if you want horizontal stacking inside the weighted slot.

Parameters

weight

share of the remaining space; must be > 0.