Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Xamarin Android Animated Splash Screen

Ajay_SBSICAjay_SBSIC USMember ✭✭✭

Hi , I am trying to add Animated Splash in my xamarin Android App , so I added a new activity (Splash Activity) and created a layout where I am displaying a GIF image but after adding this I am getting a black screen after Animation for 2 to 3 seconds. as I observe my Main class is taking time to load and that is why I am getting black screen the same thing is not happening if I directly add a theme (static image).

Can anyone please suggest me how can I resolve this or at-least suggest me any better approach to implement Animated Splash in Xamarin Android project. Thanks.

Best Answer

Answers

  • YelinzhYelinzh Member, Xamarin Team Xamurai

    Have you used Task in your SplashActivity? If so, remove the Task and try again.

  • Ajay_SBSICAjay_SBSIC USMember ✭✭✭

    I did not used Task, Actually that was happening because of My shared project after main page called. In my main page multiple api's are calling so I used Gif image (same as splash image to show animation until my data is loaded). It is working fine but I still have a query ... after splash I am getting a flick for 100 or 200 ms how can I avoid this flicker ? below is my splash screen code :

    protected override void OnResume()
            {
                base.OnResume();
                var intent = new Intent(this, typeof(MainActivity));
                intent.AddFlags(ActivityFlags.NoAnimation);
                this.Window.TransitionBackgroundFadeDuration = 0;
                if (Intent.Extras != null)
                    intent.PutExtras(Intent.Extras);
                StartActivity(intent);
                Finish();
            }
    
  • Ajay_SBSICAjay_SBSIC USMember ✭✭✭

    Thanks , it works fine but once I close the app and reopen it took time to start and also starts with a Black screen

    here is my style code :

        <style name="splashscreen" parent="Theme.AppCompat.Light.NoActionBar">
            <item name="android:windowBackground">@drawable/splashscreen</item>
            <item name="android:windowNoTitle">true</item>
            <item name="android:windowDisablePreview">true</item>
            <item name="android:windowIsTranslucent">false</item>
            <item name="android:windowIsFloating">false</item>
            <item name="android:windowActionBar">false</item>
            <item name="android:windowFullscreen">true</item>
            <item name="android:windowContentOverlay">@null</item>
          </style>
    
  • YelinzhYelinzh Member, Xamarin Team Xamurai
    edited March 2019

    You can try to move the code to OnCreate method.

    protected override void OnCreate()
            {
                base.OnCreate();
                var intent = new Intent(this, typeof(MainActivity));
                intent.AddFlags(ActivityFlags.NoAnimation);
                this.Window.TransitionBackgroundFadeDuration = 0;
                if (Intent.Extras != null)
                    intent.PutExtras(Intent.Extras);
                StartActivity(intent);
                Finish();
            }
    
  • Ajay_SBSICAjay_SBSIC USMember ✭✭✭

    already did , but it did not works , still getting black screen

  • Hello,

    If you find the gif splash on your xamarin forms project then find the solution from following link. Black screen issue resolved in this video. Have a look.
    youtu.be/YR5YQBb-Fns

    Thanks.

Sign In or Register to comment.