Xamarin Android Lottie启动画面

时间:2018-07-31 18:26:02

标签: xamarin lottie-android

https://www.project-respite.com/lottie-xamarin-forms/

我不知道我在做什么错。我按照了教程中的步骤进行操作,但是却收到此错误“视图不包含'AddAnimationListner'的定义...”

我也尝试过使用以下[1]类:addAnimatorUpdateListener和addAnimationListner。

该如何解决?

代码: 屏幕截图 https://imgur.com/a/02KDU9w

using Android.Animation;
using Android.App;
using Android.Content;
using Android.OS;
using Lottie.Forms.Droid;
using Com.Airbnb.Lottie;


namespace RefrigerantID.Droid
{
    [Activity(Theme = "@style/Theme.Splash",
        MainLauncher = true,
        NoHistory = true)]
    public class SplashActivity : Activity, Animator.IAnimatorListener
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.splash);

            var animationView = FindViewById(Resource.Id.animation_view);
            animationView.AddAnimationListener(this);
        }

        public void OnAnimationCancel(Animator animation)
        {
        }

        public void OnAnimationEnd(Animator animation)
        {
            StartActivity(new Intent(Application.Context, typeof(MainActivity)));
        }

        public void OnAnimationRepeat(Animator animation)
        {
        }

        public void OnAnimationStart(Animator animation)
        {
        }
    }
}

1 个答案:

答案 0 :(得分:1)

那......

var animationView = FindViewById<LottieAnimationView>(Resource.Id.animation_view);
animationView.AddAnimationListener(this);