Compose Modifier

layout

Creates a [LayoutModifier] that allows changing how the wrapped element is measured and laid out.

ConvenienceLayoutModifierSample

@Composable
fun ConvenienceLayoutModifierSample() {
    Box(
        Modifier.background(Color.Gray).layout { measurable, constraints ->
            // an example modifier that adds 50 pixels of vertical padding.
            val padding = 50
            val placeable = measurable.measure(constraints.offset(vertical = -padding))
            layout(placeable.width, placeable.height + padding) {
                placeable.placeRelative(0, padding)
            }
        }
    ) {
        Box(Modifier.fillMaxSize().background(Color.DarkGray))
    }
}