[英]Android Xamarin: Detect Lottie Animation End
I want to inflate a Layout-File in my DialogFragment which only holds one LottieAnimationView 我想在仅包含一个LottieAnimationView的DialogFragment中添加一个布局文件
<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
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. 但是我找不到找到
onAnimationEnd
方法或类似方法的方法。
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: 您需要使用IAnimatorListener侦听器,只需在您的类中实现即可:
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: 然后将IAnimatorListener实现分配为Lottie视图的动画监听器:
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 您可以在Lottie Xamarin github上找到完整的示例: https : //github.com/martijn00/LottieXamarin/blob/develop/Samples/Native/Example.Droid/AnimationFragment.cs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.