How to Remove White Screen Before Android App Starts

Retrofit Android Library
1 January 2017

How to Remove White Screen Before Android App Starts

This Blog will show how to make splash screen the right way so that user dont have to see white screen before android app start.To do this first we have to create XML drawable in res/drawable.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

     <item
         android:drawable="@color/gray"/>
     <item>
          <bitmap
          android:gravity="center"
          android:src="@mipmap/ic_launcher"/>
     </item>

</layer-list>

Here we set splash screen with grey color and icon on middle.You can make whatever you want. Now we have to make a theme and for that go to style.xml


<resources>

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

     <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
         <item name="android:windowBackground">@drawable/background_splash </item>
     </style>

</resources>

Now we have to configure our splash activity to use splash theme in Android Manifest


<activity
     android:name=".SplashActivity"
     android:theme="@style/SplashTheme">
     <intent-filter>
          <action android:name="android.intent.action.MAIN" />
         <category android:name="android.intent.category.LAUNCHER" />
     </intent-filter>
</activity>

Now we are all set. Now when you run the app you will see no white screen instead you will see drawable xml we designed. Now start your main activity instantly or with timer its upto you.



By Lakshay Jain

Tags: Android, Splash Screen