I want to inflate a Layout-File in my DialogFragment which only holds one LottieAnimationView
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/animViewTest1"
android:layout_height="100dp"
android:layout_width="100dp"
app:lottie_fileName="json_Saved.json"
app:lottie_loop="false"
app:lottie_autoPlay="false"
/>
I want the Fragment to show up, play the animation once, and automatically close, after the animation is finished.
I can access the AnimView
animView = view.FindViewById<LottieAnimationView>(Resource.Id.animViewTest1);
animView.PlayAnimation();
but i can't find a way to get to the onAnimationEnd
Method or something similar.
I found this similar question: How to know when lottie animation is completed?
But it does not helped me to make it work in my case.
You need to use IAnimatorListener listener, just implement it by your class:
YourClass : IAnimatorListener
with all needed methods, one of them is what you're after:
public void OnAnimationEnd(Animator animation)
{
// your logic on animation end
}
and then assign your IAnimatorListener implementation as animator listener of your lottie view:
this.animationView.AddAnimatorListener(implementationOfIAnimatorListener);
You can find a full example on Lottie Xamarin github: https://github.com/martijn00/LottieXamarin/blob/develop/Samples/Native/Example.Droid/AnimationFragment.cs
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.