Cordova - 尝试控制 Android 12 的新启动屏幕

问题描述 投票:0回答:3

我是 Cordova 用户,而不是 Android 专家! 我已经看到了这个问题的答案,这些答案需要大量的 Android 知识和不断变化的 Java 代码。

我正在尝试控制Android 12中引入的新启动屏幕。我想将默认背景更改为白色。 更好的是用我自己的静态图像替换这个新的启动屏幕。

我已将编译 SDK 更新到 31 并添加了 core-splashscreen:1.0.0-alpha02。 这从启动屏幕上删除了我的徽标,这很棒。 现在我想改变背景颜色。 我尝试过样式和主题文件但没有成功。

我确信有很多 Cordova 用户都在为此苦苦挣扎。 任何帮助都会很棒!

非常感谢,乔恩

android cordova splash-screen android-12
3个回答
0
投票

您可以向

config.xml
添加几个属性,这些属性将允许您控制启动屏幕的颜色。

    <platform name="android">
        ...
        <preference name="AndroidWindowSplashScreenBackground" value="#FFFFFF" />
        <preference name="AndroidWindowSplashScreenIconBackgroundColor" value="#FFFFFF" />
        ...
    </platform>

有关它的更多信息可以在 Cordova 博客Cordova 启动画面文档

上找到

0
投票

这在 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"

0
投票

大家好,我遇到了同样的问题。 我的意思是只有初始屏幕背景更改为白色,当我使用任何其他颜色时,它无法正常工作并以黑色显示。

        <preference name="AndroidWindowSplashScreenBackground" value="#080D24" />

解决了 经过几个小时的研究后,我发现当您的移动应用程序深色主题启用时,启动屏幕背景将是黑色白色

已解决:

禁用深色模式将应用任何其他背景颜色作为飞溅 屏幕。

splash screen with background 希望它会有所帮助:)

© www.soinside.com 2019 - 2024. All rights reserved.