Splash Screen API in Android 12
Android 12 introduces the SplashScreen API, which allows all apps to use a new app to start an animation. When you or the user starts the application it fires up. The new experience incorporates common design components into every app launch, but it is also configurable, allowing your app to retain its distinct branding. You may use the SplashScreen compact library, which encapsulates the SplashScreen API, in addition to the SplashScreen API directly.
Function of Splash Screen
The following occurrences occur when a user starts an app when the app’s process is not started (a cold start) or the Activity has not been generated (a warm start). (During a hot start, the splash screen is never displayed.)
- You can tailor the experience from start to end.
- When the app is finished, the splash screen disappears and the app is shown.
Animation Elements and Mechanics
The animation’s components are described via XML resource files in the Android Manifest. Each has a bright and dark mode variant.
They are as follows:
- window background
- animated app icon, and
- icon background
Keep the following things in mind while using these elements:
- The app icon should be vector drawable and static or dynamic. Although animations can be of any length, we recommend that they do not exceed 1,000 milliseconds. The launcher icon is used by default.
- The icon background is optional, however, it is beneficial if there is a requirement for additional contrast between the icon and the window backdrop. If you use an adaptable icon, its backdrop is displayed if the contrast between it and the window background is high enough.
- The backdrop of the window (4) is made up of a single opaque color. If the window background is set to a simple color and is not set, it is utilized by default if the attribute is not set.
Geek Tip: Enter and leave animations are used in the splash screen animation mechanics.
The system view to the splash screen is included in the entrance animation. This is managed by the system and cannot be changed. The leave animation is made up of an animation run that hides the splash screen. Like mentioned earlier everything is fully tailored from the start as you need it. When the animation is finished, the splash screen must be manually deleted.
Customize Your App’s Splash Screen
If you have a window background in your app theme the splash screen will utilize it. The splash screen is customized by adding characteristics to the app theme.
The splash screen of your app may be modified in the following ways:
- Changing the theme’s look by changing its characteristics
- Keeping it on the screen for a longer amount of time
- Changing the animation used to dismiss the splash screen
Change the appearance of the splash screen by assigning it a theme.
Step #1: Adding Characteristics
To modify your app’s splash screen, you may provide the following characteristics in your Activity theme. Consider supplying an additional resource file for Android 12 if you currently have a historical splash screen implementation that utilizes characteristics like android: windowBackground.
Step #2: Adding Drawable
To change an icon in the middle of the beginning window, use windowSplashScreenAnimatedIcon. If you want to animate your logo or splash, then you can add that too!
Step #3: The Minutiae
To specify the duration of the splash screen icon animation, use windowSplashScreenAnimationDuration. Setting this has no influence on the actual time the splash screen is shown, but you may obtain it when designing the splash screen exit animation using SplashScreenView#getIconAnimationDuration. For further information, see Keep the splash screen on for longer durations in the next section.
So by this, you now know how to add splash screen in the Android 12 way, it’s easy and more smooth than any other previous implementation and is faster and better.