Jonathan
07/15/2024, 6:40 PMAlignment.TopCenter
I’ve made the child composable twice the height of the parent because my intention for it is programmatically scroll content to eventually reveal the content beneath, so making the child box scrollable won’t work because I want to completely scroll its contents off screen.
BoxWithConstraints(
modifier = Modifier.fillMaxSize(),
) {
Box(
modifier = Modifier
.align(
Alignment.TopCenter
)
.requiredSize(
width = maxWidth,
height = maxHeight * 2
)
) {
Text(
text = "Top Text",
fontSize = 48.sp,
modifier = Modifier.align(Alignment.TopStart),
)
Text(
text = "Bottom Text",
fontSize = 48.sp,
modifier = Modifier.align(Alignment.BottomStart),
)
}
}}
Screenshot of the preview window?Zach Klippenstein (he/him) [MOD]
07/15/2024, 7:07 PMZach Klippenstein (he/him) [MOD]
07/15/2024, 7:08 PMJonathan
07/15/2024, 7:08 PMZach Klippenstein (he/him) [MOD]
07/15/2024, 7:11 PMJonathan
07/15/2024, 7:12 PMZach Klippenstein (he/him) [MOD]
07/15/2024, 7:14 PMZach Klippenstein (he/him) [MOD]
07/15/2024, 7:16 PMVerticalScrollAxisRange
, scrollBy
, and scrollByOffset
Zach Klippenstein (he/him) [MOD]
07/15/2024, 7:20 PMplaceWithLayer
and use the layer to offset your content. It’s much cheaper to scroll by layer offset than normal offset.Jonathan
07/15/2024, 7:21 PMZach Klippenstein (he/him) [MOD]
07/15/2024, 7:21 PMZach Klippenstein (he/him) [MOD]
07/15/2024, 7:22 PMJonathan
07/15/2024, 7:24 PMJonathan
07/15/2024, 7:25 PMZach Klippenstein (he/him) [MOD]
07/15/2024, 7:26 PMJonathan
07/15/2024, 7:31 PMZach Klippenstein (he/him) [MOD]
07/15/2024, 7:36 PMZach Klippenstein (he/him) [MOD]
07/15/2024, 7:36 PMAnimatable
, then you know when the animation is done when animateTo
returns.Jonathan
07/15/2024, 7:37 PMBoxWithConstraints(
modifier = Modifier
.background(Color.LightGray)
.fillMaxSize()
) {
var currentState = remember { MutableTransitionState(false) }
currentState.targetState = true
val transition = rememberTransition(currentState, label = "selected state")
val yOffset by transition.animateDp(
transitionSpec = {
tween(durationMillis = 5500, easing = LinearEasing)
},
label = "yOffset"
) {
if (it) maxHeight else -(maxHeight * .0F)
}
}
I’m using transition because I want to rotate the “confetti” as it’s vertically scrolling.Jonathan
07/15/2024, 8:08 PMJonathan
07/15/2024, 8:09 PMZach Klippenstein (he/him) [MOD]
07/15/2024, 8:14 PM