如何将堆叠动画应用于jetpack compose中列可组合项内的可组合项?

问题描述 投票:0回答:1

我有一个可组合的语言列表。我想将堆叠动画应用于

Column()
可组合项中的所有可组合项。我为此编写了一些代码并且它部分工作。它同时为所有
Column()
可组合项设置动画。但我希望每个
RadioButtonChip()
可组合项的动画有一些延迟,这样它就能给人堆叠动画的感觉。
RadioButtonChip()


android-jetpack-compose android-animation
1个回答
0
投票
val animateOffsetY = remember { Animatable(300f) } LaunchedEffect(Unit) { languages.forEachIndexed { index, _ -> delay(index.toLong() * 200) animateOffsetY.animateTo(0f, animationSpec = tween(500)) } } Column( modifier = modifier.fillMaxSize() ) { languages.forEachIndexed { index, language -> RadioButtonChip( modifier = Modifier .fillMaxWidth(0.5f) .offset { IntOffset(0, animateOffsetY.value.roundToInt()) }, languageName = language.languageName ) } }

。如果您有

Animatable
列表,每个 RadioButtonChip 将有其各自的动画,例如
Animatable

© www.soinside.com 2019 - 2024. All rights reserved.