Ionic 3 android平台上的启动画面无法正常工作

时间:2017-12-21 01:24:10

标签: ionic-framework ionic2 ionic3

我一直在寻找3天的答案而无法找到答案,我已经安装了插件(cordova-plugin-splashscreen)并将插件最新降级到2.0.0,重新定位了我的图片并将我的文件夹/资源重命名为/ res,将它放到platforms / android / src / main / res文件夹中仍然无效。这是我的config.xml

<platform name="android">
    <allow-intent href="market:*" />
    <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
    <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
    <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
    <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
    <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
    <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
    <splash density="land-ldpi" src="resources/android/icon/drawable-land-ldpi-screen.png" />
    <splash density="land-mdpi" src="resources/android/icon/drawable-land-mdpi-screen.png" />
    <splash density="land-hdpi" src="resources/android/icon/drawable-land-hdpi-screen.png" />
    <splash density="land-xhdpi" src="resources/android/icon/drawable-land-xhdpi-screen.png" />
    <splash density="land-xxhdpi" src="resources/android/icon/drawable-land-xxhdpi-screen.png" />
    <splash density="land-xxxhdpi" src="resources/android/icon/drawable-land-xxxhdpi-screen.png" />
    <splash density="port-ldpi" src="resources/android/icon/drawable-port-ldpi-screen.png" />
    <splash density="port-mdpi" src="resources/android/icon/drawable-port-mdpi-screen.png" />
    <splash density="port-hdpi" src="resources/android/icon/drawable-port-hdpi-screen.png" />
    <splash density="port-xhdpi" src="resources/android/icon/drawable-port-xhdpi-screen.png" />
    <splash density="port-xxhdpi" src="resources/android/icon/drawable-port-xxhdpi-screen.png" />
    <splash density="port-xxxhdpi" src="resources/android/icon/drawable-port-xxxhdpi-screen.png" />
</platform>
<plugin name="cordova-plugin-splashscreen" spec="^2.0.0" />

2 个答案:

答案 0 :(得分:0)

从CLI创建新项目时,例如:

executemany()

你会得到一个有效的默认启动画面。

添加平台:

cur.executemany("""
    INSERT INTO 
        Produit
        (nom_product, price, rating) 
    VALUES
        (:nom_produit, :prix, :note)
""", ListProduct)

ionic start testProject blank 文件夹中的ionic cordova platform add android ionic cordova platform add ios 图片外,请勿更改任何内容。

然后运行命令:

splash.png

这将创建所有资源并将它们放在所有paltforms的正确文件夹中,并更新\resources文件。

在Android设备上运行该项目:

ionic resources

答案 1 :(得分:0)

使用cordova-plugin-splashscreen版本4.0.1。   config.xml中

<plugin name="cordova-plugin-splashscreen" spec="~4.0.1"/>
<platform name="android">
    <allow-intent href="market:*"/>
    <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png"/>
    <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png"/>
    <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png"/>
    <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png"/>
    <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png"/>
    <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png"/>
    <splash density="land-ldpi" src="resources/android/splash/drawable-land-ldpi-screen.png"/>
    <splash density="land-mdpi" src="resources/android/splash/drawable-land-mdpi-screen.png"/>
    <splash density="land-hdpi" src="resources/android/splash/drawable-land-hdpi-screen.png"/>
    <splash density="land-xhdpi" src="resources/android/splash/drawable-land-xhdpi-screen.png"/>
    <splash density="land-xxhdpi" src="resources/android/splash/drawable-land-xxhdpi-screen.png"/>
    <splash density="land-xxxhdpi" src="resources/android/splash/drawable-land-xxxhdpi-screen.png"/>
    <splash density="port-ldpi" src="resources/android/splash/drawable-port-ldpi-screen.png"/>
    <splash density="port-mdpi" src="resources/android/splash/drawable-port-mdpi-screen.png"/>
    <splash density="port-hdpi" src="resources/android/splash/drawable-port-hdpi-screen.png"/>
    <splash density="port-xhdpi" src="resources/android/splash/drawable-port-xhdpi-screen.png"/>
    <splash density="port-xxhdpi" src="resources/android/splash/drawable-port-xxhdpi-screen.png"/>
    <splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png"/>
  </platform>

将图像放入项目资源文件夹中 enter image description here

删除您的www文件夹并尝试重新运行

希望它会奏效。