我想使用Splash Screen API制作带有渐变背景和徽标的启动屏幕
像这样:
我对值是纯色的字段进行了样式设置windowSplashScreenBackground,效果很好:
<style name="Theme.MyApp.SplashScreen" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/blue</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
<item name="postSplashScreenTheme">@style/Theme.MyApp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
该属性windowSplashScreenBackground只能采用颜色。
有什么想法如何创建渐变背景吗?可能是这样的:
<style name="Theme.MyApp.SplashScreen" parent="Theme.SplashScreen">
...
<item name="windowSplashScreenBackground">@drawable/gradient_splash_screen_background</item>
...
</style>
Run Code Online (Sandbox Code Playgroud)
更新
我还尝试在字段中声明背景android:windowBackground而不是windowSplashScreenBackground
<style name="Theme.MyApp.SplashScreen" parent="Theme.SplashScreen">
<item name="android:windowBackground">@drawable/gradient_splash_screen_background</item>
<!-- <item name="windowSplashScreenBackground">@color/purple</item>-->
<!-- <item name="windowSplashScreenBackground">@drawable/splash_screen_layers</item>-->
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
<item name="postSplashScreenTheme">@style/Theme.MyApp</item>
</style>
Run Code Online (Sandbox Code Playgroud)
但它解决了一个问题并消耗了另一个问题。屏幕背景接受渐变但徽标变得不可见
在以前版本的 Capacitor 中,Android 上的启动屏幕是在splash.png 中指定的图像。我最近升级到了 Capacitor 4,并将目标 SDK 版本更改为 32。据我了解,Android 12 Splash screen API 现在使用您的 App Icon 作为启动屏幕,您可以自定义背景颜色、动画等。
有没有办法使用旧的行为,即将自定义图像显示为启动屏幕?
请注意,我不是 Android 开发人员,仅使用 Ionic/Capacitor 来创建应用程序,谢谢。
更新:我认为目前这是不可能的。看: