2017-11-08 12 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 
      } 
     } 
    } 
} 

희망이 있습니다.