Skip to content

Instantly share code, notes, and snippets.

@fvilarino
Created March 4, 2023 23:15
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 fvilarino/92930260c4ab6999d95ff946f1e5e432 to your computer and use it in GitHub Desktop.
Save fvilarino/92930260c4ab6999d95ff946f1e5e432 to your computer and use it in GitHub Desktop.
Ticker - Top Half
@Composable
private fun TopHalf(
modifier: Modifier = Modifier,
content: @Composable () -> Unit,
) {
// 1
Layout(
// 2
modifier = modifier.clipToBounds(),
content = content,
) { measurables, constraints ->
require(measurables.size == 1) { "This composable expects a single child" }
// 3
val placeable = measurables.first().measure(constraints)
// 4
val height = placeable.height / 2
// 5
layout(
width = placeable.width,
height = height,
) {
// 6
placeable.placeRelative(
x = 0,
y = 0,
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment