Ich arbeite mit einer komplexen Lottie -Animation in Android (Kotlin), in der ich: < /p>
Einmal einige Schichten abspielen muss (repepcount = 0) < /p>
< /li>
andere Layers loop infinpinit (prepectCount = lottTiediewable). /> < /li>
Die Sichtbarkeit der Steuerschicht dynamisch < /p>
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()
}
}
}
Wie diese Ebene ausblenden/anzeigen Ich mache
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.>
Ich arbeite mit einer komplexen Lottie -Animation in Android (Kotlin), in der ich: < /p> [list] [*] Einmal einige Schichten abspielen muss (repepcount = 0) < /p> < /li> andere Layers loop infinpinit (prepectCount = lottTiediewable). /> < /li> Die Sichtbarkeit der Steuerschicht dynamisch < /p> [code]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
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
[/list] Wie diese Ebene ausblenden/anzeigen Ich mache 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.>
Die App stürzte ab, während er die Lottie -Datei auf meiner Begrüßungsbildschirmseite rendert. mit diesem? Ich werde bei Bedarf weitere Informationen zur Verfügung stellen.
Ich möchte Lottie zu meinem CMP-Projekt für iOS hinzufügen, aber Ich möchte keine Bibliothek wie Kottie in meinem Projekt verwenden und möchte es von der Basis aus implementieren.
Wie Kottie:
tl; Dr. Ich bekomme eine unendliche Schleife, wenn ich mein Django -Backend fordere, und ich weiß nicht, wie ich es beheben kann. Cloudfare-Domain, und ich habe mich auf der Eisenbahn von Backend...