Xamarin : Splash Screen




Xamarin : Splash Screen



1. Create images for respective resolutions and store it in the same folder in Resources folder of "ProjectName.Droid" project

MDPI         =  320 × 480 dp = 320x480px (The Default x1)
XHDPI       =  2 x MDPI = 640x960px
XXHDPI     =  3 x MDPI = 960x1440px
XXXHDPI   =  4 x MDPI = 1280x1920px


2. Create new activity name "SplashActivity.cs" in Droid project 

    [Activity(Theme = "@style/Theme.Splash",
        MainLauncher = true,
        NoHistory = true)]
    public class SplashActivity : Activity
    {       
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            System.Threading.Thread.Sleep(3000);
            StartActivity(typeof(MainActivity));
        }
    }

3.  Open "MainActivity.cs"  File and set MainLauncher = false

4. Set styles, open styles.xml from Resources -> Values folder 

   <style name="Theme.Splash" parent="MainTheme.Base">
    <item name="android:background">@drawable/splashscreen</item>
    <item name="windowNoTitle">True</item>
  </style>

  <style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">  </style>

5. Run the application and see the splash screen


6. For windows phone and windows 8.1 project, please follow the steps as mentioned in below image,





No comments:

Post a Comment