Home > Blockchain >  how to delay splash fragment time to complete lottie animation
how to delay splash fragment time to complete lottie animation

Time:01-05

This is my splashfragment. I have created the lottie animation which is around 3sec long and it work fine but screen changes before the animation is completed.

class SplashFragment : Fragment()  {

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?) =
        FragmentSplashBinding.inflate(inflater, container, false).root

}

CodePudding user response:

For Delay Use Handler

Handler(Looper.getMainLooper()).postDelayed({
            //Do something after 3sc
        }, 3000)

CodePudding user response:

lottieAnimationView.addAnimatorListener(object : AnimatorListener{
            override fun onAnimationStart(p0: Animator?) {
                Log.d("Lottie","Animation start")
            }

            override fun onAnimationEnd(p0: Animator?) {
                Log.d("Lottie","Animation end")
            }

            override fun onAnimationCancel(p0: Animator?) {
                Log.d("Lottie","Animation Cancelled")
            }

            override fun onAnimationRepeat(p0: Animator?) {
                Log.d("Lottie","Animation repeat")
            }

        })

Go to next screen when onAnimationEnd triggered.

  • Related