Good afternoon! How are you all?
I've been trying to implement a splash screen all day following tutorials here and there. The most common solution I found was to have a XML file in the drawable folder and call a bitmap from there. It was working fine until I tried to add a different splash for landscape. It all went downhill from there.
So I found another solution: To set the content view of my SplashActivity to an XML where I set a layout and an Image. It works perfectly for portrait and landscape in preview mode. However, when I run the app, the splash screen is nowhere to be found and it only shows a blank screen.
This is my Splash Activity.
Its XML file is:
Strangely enough, when I put the SetContentView in my MainActivity it shows in there (Even though not correctly sized) so I don't think the problem is in the XML file. I really don't know what else I could try to solve this
OnResume
will be called immediately after OnCreate
. You don't set enough time to display the splash page. Try the code below:
[Activity(Label = "SplashActivity", MainLauncher = true)] public class SplashActivity : Activity { protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.splash_layout); await Task.Delay(3000); var intent = new Intent(this, typeof(MainActivity)); StartActivity(intent); } }
Adjust the delay as you want there.
Answers
OnResume
will be called immediately afterOnCreate
. You don't set enough time to display the splash page. Try the code below:Adjust the delay as you want there.
Oh my, I tried so many things but turns out the solution was so much simpler than I thought! Thank you so much, it worked