2017-11-08 39 views
3

私はLottieアニメーションを実装しており、アニメーション全体が素晴らしい作品です!しかし、30フレーム後にアニメーションを一時停止するコードを追加して、一定時間後に再開できるようにしたいと考えています。これまでのコードはここにありますLottieアニメーションの一時停止と再開

animationView.playAnimation(0, 30) 
animationView.addAnimatorListener(object : Animator.AnimatorListener { 
    override fun onAnimationEnd(animation: Animator) { 
     if (isLoading == false) { 
     //Everything has loaded. Continue Animation 

     //This line has no effect. The animation does not continue 
     animationView.playAnimation(30, 60) 
     //Resuming the animation just makes the animation disappear 
     //animation.resume() 
     } 
} 

何かアドバイスありがとうございます!

答えて

3

LottieAnimationView、スレッドとフラグから進捗を使用し、あなたが何ができるかである、これはあなたが再び

をあなたのアニメーションを再生する必要があり、正確に一定の進展で一時停止履歴書にあなたをできるようになります私は次の例を作成しました:

animationView.playAnimation() 
animationView.loop(false) 

isAnimating = true // Setup your flag 

thread { 
    while (isAnimating){ // Loop that checks the progress of your animation 
     if (animationView.progress >= 0.5f){// If animation reaches 50% 
      runOnUiThread { 
       animationView.pauseAnimation()// Pause Animation 
      } 
      Thread.sleep(5000) // Pause for 5 seconds 
      runOnUiThread { 
       animationView.playAnimation(0.5f,1f) // Resume your animation from 50% to 100% 
      } 
      isAnimating = false 
     } 
     if(animationView.progress >= 1f){ // If animation reaches 100% stop animation 
      runOnUiThread { 
       animationView.cancelAnimation() 
       isAnimating = false 
      } 
     } 
    } 
} 

希望します。

関連する問題