I'm trying to use AnimatedVectorDrawable
as a splash animation placed in the window background. I use the official example given in https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html. It appears but doesn't animate.
Are animations in a Window
background possible at all?
Go to app > java > first package name > right-click > New > Activity > Empty Activity and create another activity and named it as SplashScreen. Edit the activity_splash_screen. xml file and add image, text in the splash screen as per the requirement.
android:background is the background color (drawable to be precise) of a view component whereas android:windowBackground is the background color of the window (activity or dialog) in which your view resides.
The first screen that you see when opening an app for the first time (cold start) is a screen placeholder create by the WindowManager
. It creates the placeholder by getting resources that you set on your theme, like the window background and status bar color. To start the animation of your window background you have to call its start()
method, but the WindowManager
is a system service that you have little or no control over. So on this phase of application initialisation, unless there is some obscure way to control the WindowManager
in the Application.onCreate()
method, it is not possible to animate the vector background.
I opened from cold start a lot of my apps including Google ones and not a single one seems to implement animations on the cold start phase (like the docs of Material Design imply possible). A very few make animations after the cold start at the onCreate of the main activity.
If it's not a problem start the animation after he cold start, like in the case of moving the logo to the top of the screen, you can:
android:windowBackground
to your static drawable at your launch activity in AndroidManifest.xmlstart()
method of your AnimatedVectorDrawable.Here is an AndroidDeveloper's post explaining in details how to deal with application themes for launch screens
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With