phonegap - Android应用的启动画面不起作用

时间:2015-07-23 10:27:18

标签: android cordova phonegap-plugins

我在phonegap cordova build(版本3.7)中为flash屏幕实现添加了以下配置:

<preference name="permissions" value="none"/>
  <preference name="orientation" value="default"/>
  <preference name="target-device" value="universal"/>
  <preference name="fullscreen" value="false"/>
  <preference name="webviewbounce" value="true"/>
  <preference name="prerendered-icon" value="true"/>
  <preference name="stay-in-webview" value="false"/>
  <preference name="ios-statusbarstyle" value="black-opaque"/>
  <preference name="detect-data-types" value="true"/>
  <preference name="exit-on-suspend" value="false"/>
  <preference name="show-splash-screen-spinner" value="true"/>
  <preference name="auto-hide-splash-screen" value="true"/>
  <preference name="disable-cursor" value="false"/>
  <preference name="android-minSdkVersion" value="7"/>
  <preference name="android-installLocation" value="auto"/>
  <preference name="SplashScreen" value="screen" />
  <preference name="SplashScreenDelay" value="10000" />

并在同一个配置文件中添加了<gap:plugin name="org.apache.cordova.splashscreen" />。以下是配置文件中的路径设置:

  <gap:splash src="www/res/screen/android/screen-ldpi-portrait.png" gap:platform="android" gap:qualifier="port-ldpi"/>
  <gap:splash src="www/res/screen/android/screen-mdpi-portrait.png" gap:platform="android" gap:qualifier="port-mdpi"/>
  <gap:splash src="www/res/screen/android/screen-hdpi-portrait.png" gap:platform="android" gap:qualifier="port-hdpi"/>
  <gap:splash src="www/res/screen/android/screen-xhdpi-portrait.png" gap:platform="android" gap:qualifier="port-xhdpi"/>
  <gap:splash src="www/res/screen/blackberry/screen-225.png" gap:platform="blackberry"/>
  <gap:splash src="www/res/screen/ios/screen-iphone-portrait.png" gap:platform="ios" width="320" height="480"/>
  <gap:splash src="www/res/screen/ios/screen-iphone-portrait-2x.png" gap:platform="ios" width="640" height="960"/>
  <gap:splash src="www/res/screen/ios/screen-iphone-portrait-568h-2x.png" gap:platform="ios" width="640" height="1136"/>
  <gap:splash src="www/res/screen/ios/screen-ipad-portrait.png" gap:platform="ios" width="768" height="1024"/>
  <gap:splash src="www/res/screen/ios/screen-ipad-landscape.png" gap:platform="ios" width="1024" height="768"/>
  <gap:splash src="www/res/screen/windows-phone/screen-portrait.jpg" gap:platform="winphone"/>
  <gap:splash src="screen.png" />



<gap:plugin name="org.apache.cordova.splashscreen"/>

<icon src="icon.png"/>
  <icon src="res/icon/android/icon-36-ldpi.png" gap:platform="android" gap:qualifier="ldpi"/>
  <icon src="res/icon/android/icon-48-mdpi.png" gap:platform="android" gap:qualifier="mdpi"/>
  <icon src="res/icon/android/icon-72-hdpi.png" gap:platform="android" gap:qualifier="hdpi"/>
  <icon src="res/icon/android/icon-96-xhdpi.png" gap:platform="android" gap:qualifier="xhdpi"/>
  <icon src="res/icon/blackberry/icon-80.png" gap:platform="blackberry"/>
  <icon src="res/icon/blackberry/icon-80.png" gap:platform="blackberry" gap:state="hover"/>
  <icon src="res/icon/ios/icon-57.png" gap:platform="ios" width="57" height="57"/>
  <icon src="res/icon/ios/icon-72.png" gap:platform="ios" width="72" height="72"/>
  <icon src="res/icon/ios/icon-57-2x.png" gap:platform="ios" width="114" height="114"/>
  <icon src="res/icon/ios/icon-72-2x.png" gap:platform="ios" width="144" height="144"/>
  <icon src="res/icon/webos/icon-64.png" gap:platform="webos"/>
  <icon src="res/icon/windows-phone/icon-48.png" gap:platform="winphone"/>
  <icon src="res/icon/windows-phone/icon-173-tile.png" gap:platform="winphone" gap:role="background"/>

  <gap:splash src="splash.png" />
  <platform name="android">
        <gap:splash src="res/screen/android/screen-ldpi-portrait.png"  gap:density="land-ldpi"/>
        <gap:splash src="res/screen/android/screen-mdpi-portrait.png"  gap:density="land-mdpi"/>
        <gap:splash src="res/screen/android/screen-hdpi-portrait.png"  gap:density="land-hdpi"/>
        <gap:splash src="res/screen/android/screen-xhdpi-portrait.png"  gap:density="land-xhdpi"/>

        <gap:splash src="res/screen/android/screen-ldpi-portrait.png"  gap:density="port-ldpi"/>
        <gap:splash src="res/screen/android/screen-mdpi-portrait.png"  gap:density="port-mdpi"/>
        <gap:splash src="res/screen/android/screen-hdpi-portrait.png"  gap:density="port-hdpi"/>
        <gap:splash src="res/screen/android/screen-xhdpi-portrait.png" gap:density="port-xhdpi"/>
  </platform>

  <platform name="ios">

  <gap:splash src="res/screen/ios/screen-iphone-portrait.png"  width="320" height="480"/>
  <gap:splash src="res/screen/ios/screen-iphone-portrait-2x.png"  width="640" height="960"/>
  <gap:splash src="res/screen/ios/screen-iphone-portrait-568h-2x.png"  width="640" height="1136"/>
  <gap:splash src="res/screen/ios/screen-ipad-portrait.png"  width="768" height="1024"/>
  <gap:splash src="res/screen/ios/screen-ipad-landscape.png" width="1024" height="768"/>

  </platform>

尝试从<gap:splash src="splash.png" />更改为<gap:splash src="screen.png" />

或从<preference name="SplashScreen" value="screen" /><preference name="SplashScreen" value="splash" />

但没有任何事情发生...... 那么剩下的设置呢? 以及xml文件中的www / cofig.xml文件 我必须改变我的编码如何做到这一点。

2 个答案:

答案 0 :(得分:0)

试试这个,它对我有用。在config.xml文件中添加两行:

<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="10000"/>

android的配置文件路径:res-&gt; xml-&gt; config.xml

还将你的启动画面放到android drawable文件夹中,如drawable-hdpi等。将启动画面的可绘制名称保存到screen.png

答案 1 :(得分:0)

尝试安装官方启动画面插件:

https://github.com/apache/cordova-plugin-splashscreen