Android Studio can be overwhelming for the beginners who are new to App Development in Android. We bring you easy steps with coding to make your App\’s Splash Screen in no time. The total time required to complete the following tutorial is not more than 10 minutes. We have explained the process in steps with code for you to copy and paste as you go. This can also be known as Rapid Application Development in Android Studio which will boost your development skills as well as reduce your App Development time. Lets get started then shall we.
We will assume that you have already opened Android Studio and have created your project with Main Activity as blank.
Go to Java Folder -> 1st Folder which would be something like au.com.techwrath.pubgclanchallenge in our case.
When you open the above folder you will see MainActivity.java class in it. You can ignore that file for now.
Once the file is created, double click the SplashScreen.java file to open it. Add the following code in the file
package au.com.techwrath.pubgclanchallenge;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;public class SplashScreen extends AppCompatActivity {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);//We will use the following code to load Splash Screen first then move it to Main Activity
startActivity(new Intent(this, MainActivity.class));
}
}
Next step is to give the splash screen a background color. We need to assign the background color for when the Splash Screen will come.
<!– Custom Colors –>
<color name=\”colorSplashScreenBG\”>#ffffff</color>
Full code would look something like
<?xml version=\”1.0\” encoding=\”utf-8\”?>
<resources>
<color name=\”colorPrimary\”>#008577</color>
<color name=\”colorPrimaryDark\”>#00574B</color>
<color name=\”colorAccent\”>#D81B60</color>
<!– Custom Colors –>
<color name=\”colorSplashScreenBG\”>#ffffff</color>
</resources>
Next step involves us to assign a Resource File to the Splash Screen so that it is easily editable in the future and we can change the structure of the Splash Screen as we please.
Open the file that you just created. In the file add the following code and change the layout format to Layer-List.
<layer-list xmlns:android=\”http://schemas.android.com/apk/res/android\”>
</layer-list>
Next add the color of background and image of logo as splash screen. In our case the image name is pubg_clan_challenge_splash_screen. The whole code would look like the following:
<?xml version=\”1.0\” encoding=\”utf-8\”?>
<layer-list xmlns:android=\”http://schemas.android.com/apk/res/android\”>
<item android:drawable=\”@color/colorSplashScreenBG\” />
<item>
<bitmap android:src=\”@drawable/pubg_clan_challenge_splash_screen\”
android:gravity=\”center\” />
</item>
</layer-list>
Next step for us will be to add the style attribute to the Splash Screen.
Add the following line of code between the <resources> your code </resource> tags after the default
<style name=\”bgSplashScreenStyle\” parent=\”Theme.AppCompat.Light.NoActionBar\”>
<item name=\”android:windowBackground\”>@drawable/background_splashscreen</item>
</style>
Full New file would look like
<resources>
<!– Base application theme. –>
<style name=\”AppTheme\” parent=\”Theme.AppCompat.Light.DarkActionBar\”>
<!– Customize your theme here. –>
<item name=\”colorPrimary\”>@color/colorPrimary</item>
<item name=\”colorPrimaryDark\”>@color/colorPrimaryDark</item>
<item name=\”colorAccent\”>@color/colorAccent</item>
</style><style name=\”bgSplashScreenStyle\” parent=\”Theme.AppCompat.Light.NoActionBar\”>
<item name=\”android:windowBackground\”>@drawable/background_splashscreen</item>
</style></resources>
Next step is to let Android Studio know that Splash Screen is the first Activity for the App.
<activity android:name=\”.SplashScreen\” android:theme=\”@style/bgSplashScreenStyle\”>
<intent-filter>
<action android:name=\”android.intent.action.MAIN\” />
<action android:name=\”android.intent.action.VIEW\” /><category android:name=\”android.intent.category.LAUNCHER\” />
</intent-filter>
</activity>
Change the Main Activity Code to the the following
<activity android:name=\”.MainActivity\” android:theme=\”@style/AppTheme\”>
<intent-filter>
<action android:name=\”android.intent.action.MAIN\” />
<action android:name=\”android.intent.action.VIEW\” /><category android:name=\”android.intent.category.DEFAULT\” />
</intent-filter>
</activity>
Save the project and click the Play Button to run the project. Make sure you have Emulator Installed or have an android device attached with your system so the App can run in it. You will see the Splash Screen loading before the Main Activity. Do remember that this is the recommended way of adding splash screen for android development in android studio in 2020. This will help boost your app on Google Play Store as well. We hope that you have had a chance to taste the Rapid Application Development in Android Studio method and we have helped you in the process.
Address: 244, Ground Floor, Raja Center, Main Market, Gulberg 2, Lahore, Pakistan
Phone : +92-3460115477
WhatsApp: +92-3460115477
Email: enquiry@techwrath.com
3 Comments on How to add Splash Screen for App Development in Android Studio in 2020
You can certainly see your skills in the work
you write. The arena hopes for even more passionate writers such as you who aren't afraid to say how they believe.
At all times follow your heart.
Wonderful web site. A lot of useful info here. I’m sending it to a few friends ans also sharing in delicious. And of course, thanks for your effort!
I'm not sure why but this web site is loading very slow for me.
Is anyone else having this issue or is it a problem on my end?
I'll check back later on and see if the problem still
exists.