在 Android 12 中,启动画面(Splash Screen)默认是静态图像而不是动画。如果你想让启动画面动起来,你需要在 App 的主题(Theme)中设置 Splash Screen 的主题(Splash Screen Theme)。
以下是一个示例代码,可以将主题设置为与应用程序中的颜色相匹配的动画 Splash Screen:
在上面的代码示例中,windowSplashScreenBackground 属性指定了用作动画的 Splash Screen 图像资源。windowSplashScreenAnimatedIcon 属性指定了用作徽标图标的动画图像资源。windowSplashScreenBrandingLogo 属性指定了用作品牌 Logo 的图像资源。
此外,windowSplashScreenAnimationDuration 属性指定了动画的持续时间(以毫秒为单位)。
在将主题应用于 App 的时候,可以使用以下代码:
以上就是在 Android 12 中添加动态 Splash Screen 的一些示例。