Skip to content

Instantly share code, notes, and snippets.

@victorbrndls
Created October 19, 2021 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorbrndls/1ce7b6aaf27c4a6c898f4fa562876550 to your computer and use it in GitHub Desktop.
Save victorbrndls/1ce7b6aaf27c4a6c898f4fa562876550 to your computer and use it in GitHub Desktop.
Layout(
modifier = modifier,
content = content
) { measurables, constraints ->
// Don't constrain child views further, measure them with given constraints
val placeables = measurables.map { measurable -> measurable.measure(constraints) }
// Set the size of the layout as big as it can
layout(constraints.maxWidth, constraints.maxHeight) {
var yPosition = 0
placeables.forEach { placeable ->
placeable.placeRelative(x = 0, y = yPosition)
yPosition += placeable.height
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment