我的Cordova启动屏幕无法在Android上工作

u91tlkcl  于 11个月前  发布在  Android
关注(0)|答案(1)|浏览(181)

我正在使用Cordova构建一个应用程序。除了闪屏之外,其他功能都可以正常工作。最近有人使用过吗?下面是我的代码:config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.hello" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>HelloWorld</name>
    <description>Sample Apache Cordova App</description>
    <author email="[email protected]" href="https://cordova.apache.org">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    
    <platform name="android">
        <preference name="SplashScreen" value="screen" />
        <preference name="SplashScreenDelay" value="3000" />
        <preference name="SplashMaintainAspectRatio" value="true" />
        <icon density="ldpi" src="res/icon/android/icon-36-ldpi.png" />

        <!-- Use the AndroidWindowSplashScreen preferences for splash screen configurations -->
        <preference name="AndroidWindowSplashScreen" value="screen" />
        <preference name="AndroidWindowSplashScreenAnimationDuration" value="2000" />
        <preference name="AndroidWindowSplashScreenContent" value="res/screen/android/land-ldpi.png" />
        <!-- Add more splash screen configurations for other densities -->
    </platform>
</widget>

字符串
这里是我的文件结构项目根平台插件www res屏幕android land-ldpi.png ios
它不工作。它继续显示默认的cordova图标,如x1c 0d1x下面的图像**所示
任何想法,我可以尝试,我已经遵循了almsot所有的资源,我可以在网上找到。任何指南,可以帮助在2023年,我将不胜感激

c7rzv4ha

c7rzv4ha1#

确保启动画面的路径正确。该路径应该相对于项目根目录。在您的情况下,启动画面应该位于res/screen/android/land-ldpi.png
如果路径正确,但启动画面图像仍然没有显示,则可能cordova-plugin-splashscreencordova-android@11已弃用,您应该使用新的启动画面API。您可以分别使用AndroidWindowSplashScreenAnimatedIconAndroidWindowSplashScreenBackground首选项设置启动画面图像和背景颜色:

<preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/android/splash/xxxhdpi.png" />
<preference name="AndroidWindowSplashScreenBackground" value="#6dADDF" />

字符串
在上面的代码中,res/android/splash/xxxhdpi.png是图像文件的路径#6dADDF设置整个启动画面的背景颜色

  • 如果您仍然面临问题,您可能需要删除引用已弃用的cordova-plugin-splashscreen的任何标记。这些标记可能会导致与新的启动画面API冲突。

相关问题