Create Splashscreen With Layout Xamarin
Im trying to create a splashscreen in Xamarin Studio. I did the following: Created my layout with the splashimage. Created a theme (styles.xml) so the titlebar was hidden. Created
Solution 1:
The screen is blank because by calling Thread.Sleep
then StartActivity
in OnCreateView
, you are first pausing the UI thread (which will cause nothing to display) and are then exiting the activity immediately by using StartActivity
.
To fix this, shift Thread.Sleep()
and StartActivity()
into a background thread:
protectedoverridevoidOnCreate (Bundle bundle)
{
base.OnCreate (bundle);
this.SetContentView (Resource.Layout.Splash);
ImageView image = FindViewById<ImageView> (Resource.Id.evolticLogo);
image.SetImageResource (Resource.Drawable.Splash);
System.Threading.Tasks.Task.Run( () => {
Thread.Sleep (2000);
StartActivity (typeof(MainActivity));
});
}
Post a Comment for "Create Splashscreen With Layout Xamarin"