【发布时间】:2023-01-03 02:21:19
【问题描述】:
题
当布尔值发生变化时,如何使用 jetpack compose 实现类似摆动动画的效果? 据我了解,该库仅支持过渡动画或无限动画。然而,在我的例子中,没有可组合对象实际上改变了它们的目标值。在我发现的示例中,总是需要更改目标值才能真正看到动画。像这样
var isError by remember { mutableStateOf(false) }
val offset = animateIntAsState(if (isError) $targetValue else 0)
// Then have something that uses the offset and add a button that is changing the state of isError
但是,我不希望 targetValue 与最初的值不同。例如,我只想看一个关键帧动画。
【问题讨论】:
标签: android-jetpack-compose jetpack-compose-animation