- Einmal einige Schichten abspielen muss (repepcount = 0) < /p>
< /li>
andere Layers loop infinpinit (prepectCount = lottTiediewable). /> < /li>
Die Sichtbarkeit der Steuerschicht dynamisch < /p>Code: Select all
private fun updateValues(modelValue: ModelValue) { isAnimationComplete = false with(binding.viewAnimation) { // 1. Full cleanup of previous state cancelAnimation() removeAllAnimatorListeners() removeAllUpdateListeners() progress = 0f // 3. Update dynamic parts updateStatus(modelValue) // Shows/hides layers // 4. Configure initial play repeatCount = 0 repeatMode = LottieDrawable.RESTART // 5. Use composition listener to ensure proper setup addLottieOnCompositionLoadedListener { addAnimatorListener(object : Animator.AnimatorListener { override fun onAnimationStart(animation: Animator) { DevLog.d("LottieDebug", "Initial animation started") } override fun onAnimationEnd(animation: Animator) { removeAnimatorListener(this) // 6. Post to main thread with proper sequencing post { // Update app state isAnimationComplete = true previousModel = modelValue updateStatusesAnotherLayer(modelValue) // Shows/hides layers cancelAnimation() progress = 0f repeatCount = LottieDrawable.INFINITE repeatMode = LottieDrawable.RESTART // 9. Start with frame delay postOnAnimation { playAnimation() } } } override fun onAnimationCancel(animation: Animator) {} override fun onAnimationRepeat(animation: Animator) {} }) // Start initial animation playAnimation() } } }
binding.viewAnimation.addValueCallback(
KeyPath("layer_1"),
LottieProperty.TRANSFORM_OPACITY
) { 0 }
binding.viewAnimation.addValueCallback(
KeyPath("layer_2"),
LottieProperty.TRANSFORM_OPACITY
) { 100 }
< /code>
Problem:
Die unendliche Schleife (repepcount = unendlich) funktioniert nach Abschluss der ersten Animation nicht für bestimmte Ebenen.>