Splash Screen Class | Android App Development | Lecture#50 | Hive Learners

๐“–๐“ป๐“ฎ๐“ฎ๐“ฝ๐“ฒ๐“ท๐“ฐ๐“ผ

Hi Hive Learners, Our half-century will complete after this lecture. We cover many interesting topics and also learn about the Firebase database. In the future, we will start a new project to help you learn more things and logic. We will create an app that helps o manage the work for a school, college, or university. Even you can use it for personal use. In lecture 49 we show the Splash screen using a layout file. Showing the splash screen using a layout file is not a good option. As layout files also take some time to load. So in today's lecture, we will use the most efficient way to show load a splash screen. Let's get started.

GitHub Link

Use this GitHub project to clone into your directory. The following lecture will update it so you will never miss the latest code. Happy Coding!

What Should I Learn

  • The best way to implement the Splash Screen

Assignment

  • Implement the Splash screen

Procedure

First, we need to create a Drawable XML file in the drawable folder. Follow these steps.

name the file make sure it is in lowercase and does not have any special character other than underscore.

Now in this file, we need to add this code that will contain a layer of color and an image in it. I set the image width to 200 by using the Pain.net

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

    <item
        android:drawable="@color/white"/>

    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/hive_logo"/>
    </item>

</layer-list>

Now open the theme and add a custom style SplashTheme

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

Now we need o set it in the Splash Activity tag of the Manifest file. We also need to remove the setContent in the Splash_Activity.java file.

Remove the setContent from the java file. It will detach the layout file from this activity and it becomes a class rather than an empty activity.

Run the app and check if you see a white screen before the splash screen or not. You will not see any screen before the splash. It is the best way to implement the Splash screen. But we enforce the app to stay on the splash screen for 2 seconds no matter whether the user device is good or not in performance. We will fix this in the future according to our needs.


hl_divider.png

Thank You

hl_footer_banner.png



0
0
0.000
2 comments
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.ย 
ย 

0
0
0.000