在 Android 视图系统中,我们可以使用以下方式的动画监听器来获取 Lottie 动画回调。
我们如何使用Jetpack Compose添加监听器?我目前已添加以下代码以播放lottie动画。我希望在动画播放完成后接收回调。
playView = LottieAnimationView(this)
playView.addAnimatorListener(object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator?) {
}
override fun onAnimationEnd(animation: Animator?) {
}
override fun onAnimationCancel(animation: Animator?) {
}
override fun onAnimationRepeat(animation: Animator?) {
}
})
我们如何使用Jetpack Compose添加监听器?我目前已添加以下代码以播放lottie动画。我希望在动画播放完成后接收回调。
@Composable
fun PlayView() {
val animationSpec = remember { LottieAnimationSpec.RawRes(R.raw.play_anim) }
val result: LottieCompositionResult by remember { mutableStateOf(LottieCompositionResult.Loading) }
val context = LocalContext.current
LottieAnimation(
animationSpec,
modifier = Modifier
.fillMaxHeight()
.fillMaxWidth()
)
if (result is LottieCompositionResult.Success) {
//start the next flow
}
}
lottieProgressAsState
这样的东西。 - MohammadBaqer