Skip to content

Instantly share code, notes, and snippets.

@zskamljic
Last active May 30, 2021 08:01
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 zskamljic/73517b6d65693fad083ce64ecc58b175 to your computer and use it in GitHub Desktop.
Save zskamljic/73517b6d65693fad083ce64ecc58b175 to your computer and use it in GitHub Desktop.
val scrollState = rememberScrollState()
Layout(
modifier = Modifier.verticalScroll(scrollState),
content = { repeat(itemCount) { item(it) } }
) { measurables, constraints ->
val placeables = measurables.map { measurable ->
measurable.measure(constraints)
}
val itemSpacing = 16.dp.roundToPx()
layout(constraints.maxWidth, constraints.maxHeight) {
var yPosition = 0
placeables.forEach { placeable ->
placeable.placeRelative(x = 0, y = yPosition)
yPosition += placeable.height + itemSpacing
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment