我正在尝试使用AnimatedVectorDrawable
作为放置在窗口背景中的水滴动画。我使用https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html中给出的官方示例。它似乎但没有动画。
是否可以在Window
背景中制作动画?
第一次打开应用程序时看到的第一个屏幕(冷启动)是由WindowManager
创建的屏幕占位符。它通过获取您在主题上设置的资源(如窗口背景和状态栏颜色)来创建占位符。要开始窗口背景的动画,你必须调用它的start()
方法,但WindowManager
是一个你很少或根本无法控制的系统服务。因此,在应用初始化的这个阶段,除非在WindowManager
方法中有一些模糊的方法来控制Application.onCreate()
,否则不可能为矢量背景设置动画。
我从冷启动开始了很多我的应用程序,包括谷歌的应用程序,而不是一个似乎在冷启动阶段实现动画(如材料设计的文档暗示可能)。很少有人在主要活动的onCreate冷启动后制作动画。
如果不是问题,可以在冷启动后启动动画,就像将徽标移动到屏幕顶部一样,您可以:
android:windowBackground
的主题设置为静态drawablestart()
方法。这是一个AndroidDeveloper's post explaining in details how to deal with application themes for launch screens