[英]AnimatedVectorDrawable as Window background. Is it possible?
I'm trying to use AnimatedVectorDrawable
as a splash animation placed in the window background. 我正在尝试使用AnimatedVectorDrawable
作为放置在窗口背景中的初始动画。 I use the official example given in https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html . 我使用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? Window
背景中的动画是否可能?
The first screen that you see when opening an app for the first time (cold start) is a screen placeholder create by the WindowManager
. 第一次打开应用程序时看到的第一个屏幕(冷启动)是由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. 要启动窗口背景的动画,您必须调用其start()
方法,但WindowManager
是一个您几乎无法控制的系统服务。 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. 因此,在应用程序初始化的这个阶段,除非在Application.onCreate()
方法中有一些模糊的方法来控制WindowManager
,否则无法为矢量背景设置动画。
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. 很少有人在主要活动的onCreate冷启动后制作动画。
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.xml 在AndroidManifest.xml中的启动活动中将属性android:windowBackground
的主题设置为静态drawable start()
method of your AnimatedVectorDrawable. 调用AnimatedVectorDrawable的start()
方法。 Here is an AndroidDeveloper's post explaining in details how to deal with application themes for launch screens 这是AndroidDeveloper的帖子,详细解释了如何处理启动屏幕的应用程序主题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.