我是 Cordova 用户,而不是 Android 专家! 我已经看到了这个问题的答案,这些答案需要大量的 Android 知识和不断变化的 Java 代码。
我正在尝试控制Android 12中引入的新启动屏幕。我想将默认背景更改为白色。 更好的是用我自己的静态图像替换这个新的启动屏幕。
我已将编译 SDK 更新到 31 并添加了 core-splashscreen:1.0.0-alpha02。 这从启动屏幕上删除了我的徽标,这很棒。 现在我想改变背景颜色。 我尝试过样式和主题文件但没有成功。
我确信有很多 Cordova 用户都在为此苦苦挣扎。 任何帮助都会很棒!
非常感谢,乔恩
您可以向
config.xml
添加几个属性,这些属性将允许您控制启动屏幕的颜色。
<platform name="android">
...
<preference name="AndroidWindowSplashScreenBackground" value="#FFFFFF" />
<preference name="AndroidWindowSplashScreenIconBackgroundColor" value="#FFFFFF" />
...
</platform>
有关它的更多信息可以在 Cordova 博客 和 Cordova 启动画面文档
上找到这在 Android SDK 33 中对我有用: 首先在中创建一个文件 android/app/src/main/values 文件夹名为 theme.xml,代码如下:
<resources> <style name="Theme.App.SplashScreen" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/cdv_splashscreen_background</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/splash_inset</item>
<item name="windowSplashScreenAnimationDuration">200</item>
<item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
</style> </resources>
然后在android/app/src/main/res/drawable文件夹中创建一个名为splash_inset.xml的文件:
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_cdv_splashscreen"
android:insetLeft="56dp"
android:insetRight="56dp"
android:insetTop="56dp"
android:insetBottom="56dp"/>
并在 AndroidManifest.xml 中放入应用程序标签:
android:theme="@style/Theme.App.SplashScreen"