Hi,
Has anyone had any luck getting a lottie animation to work in an Xamarin Android Splash screen?
I've created a layout for my Splash screen:
PLEASE NOTE: I had to remove the http : //
from the schemas because as a first time poster on this forum I was getting an error that I couldn't post links
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="schemas.android.com/apk/res/android"
xmlns:app="schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/SunAnim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:lottie_fileName="sun_burst_icon.json"
app:lottie_loop="false"
app:lottie_autoPlay="true"
android:gravity="center" />
</LinearLayout>
and this is my SplashActivity:
using Android.Animation;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Support.V7.App;
using Android.Util;
using Com.Airbnb.Lottie;
namespace WeatherTest
{
[Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity, Animator.IAnimatorListener
{
static readonly string TAG = "WeatherTest:" + typeof(SplashActivity).Name;
LottieAnimationView animationView;
public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
{
base.OnCreate(savedInstanceState, persistentState);
SetContentView(Resource.Layout.Splash);
setup();
}
void setup()
{
animationView = FindViewById<LottieAnimationView>(Resource.Id.SunAnim);
animationView.AddAnimatorListener(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)
{
}
// Launches the startup task
protected override void OnResume()
{
base.OnResume();
if (animationView == null)
{
animationView = FindViewById<LottieAnimationView>(Resource.Id.SunAnim);
}
animationView.AddAnimatorListener(this);
animationView.PlayAnimation();
}
public override void OnBackPressed() { }
}
}
animationView always is null no matter from which lifecycle function I grab it from. The screen is always black.
I'm hoping to set it up where the animation plays and then it goes to the MainActivity when it ends