Show Billions of Android apps are there in play store. Most of the apps have one thing common, Splash Screen. Android 12 brought us the official splash screen support. Previously, we have to add a custom implementation i.e. there was no uniform way to implement it. You can implement this feature in lower versions(minimum SDK 23) also with support library. Definition of splash screenWhen your app is not in memory or its process is not active, it takes time to open. It takes time to load first frame of your app. Till then even if you implement an activity as splash, you will see a plain white screen for some time. It's better to show some graphical assets i.e. app logo, animation, background color etc. to users instead of showing white screen. This graphic is called Splash Screen. An example of splash screen animation from Android's official document: Splash screen will be shown in following scenarios:
Implementation of Splash Screen APILet's do some coding together. Step 1:Add following gradle dependency in your app level
Enter fullscreen mode Exit fullscreen mode Make sure Now sync gradle. Step 2:Create a splash theme in
Enter fullscreen mode Exit fullscreen mode where,
Step 3:Add this theme in
Enter fullscreen mode Exit fullscreen mode see Step 4Inside the launcher activity, call activity's
Enter fullscreen mode Exit fullscreen mode 😃 That's it!!! Really simple steps right? Advance StepsNow what if you want to keep the splash screen till loading some data from local or remote data source? Then you can follow some advance steps: Step 5To keep splash screen even after app came in process, you need to use pre draw listener. Modify your activity as follows:
Enter fullscreen mode Exit fullscreen mode where, Step 6If you want to exit splash screen with some animation, you can do this using extension field
Enter fullscreen mode Exit fullscreen mode For the ease of my readers, I have created Splash Demo GitHub Repo where you can see example implementation of splash screen API. ConclusionFirst impression is the last impression. If user sees blank screen on launching the app, it will create bad impact. To provide a better user experience, splash screen is a very useful API. To read more about splash screen, you can read official document. How do I use Splash display?Use the steps below to create the splash screen's theme.. Create a splash screen background in drawable/splash background. ... . Create the gradient in drawable/bg gradient. ... . Make a splash screen style in res/values/themes. ... . Set the style as the activity's theme in AndroidManifest.. What is splash API?The elements of the splash screen are defined by XML resource files in the Android Manifest. There are light and dark mode versions for each. The customizable elements of a splash screen consist of the app icon, icon background, and window background: Figure 2: Customizable elements of a splash screen.
How do I set up splash?First, run npx expo install expo-splash-screen . Next, add the following code to delay hiding the splash screen for five seconds. import * as SplashScreen from 'expo-splash-screen'; SplashScreen. preventAutoHideAsync(); setTimeout(SplashScreen.
What is a splash screen on an app?Splash Screen is the very first screen the user sees when they open up an app on a mobile device. It's the very first chance of creating a positive impact on the users. It appears while the app is loading when the user has just opened up the app. Many times the Splash screen is called a launch screen.
|