我不能让SplashScreen在Android phonegap项目上运行

时间:2014-10-29 11:39:43

标签: android cordova splash-screen

我使用CLI安装了插件:$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git

我的cordova版本是:3.4.0-0.19.17
cordova.js我的项目版本是:3.4.0

我按照文档中的说明进行操作,但我似乎无法使其正常工作。这是我的 res 目录:

enter image description here

以下是关于splashscreen的config.xml文件:

config.xml中

<feature name="SplashScreen">
    <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
</feature>

config.xml中

<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
<platform name="android">
    <splash src="www/res/drawable/splashscreen.png" />
</platform>
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="10000" /> 

index.html上的设备就绪功能:

document.addEventListener("deviceready", onDeviceReady, false);
  function onDeviceReady() {
    navigator.splashscreen.show();
    redirectTo("./main.html");
}

可能出现什么问题?

1 个答案:

答案 0 :(得分:1)

   follow the instructions on the PhoneGap documentation page:                                        
   http://docs.phonegap/en/3.4.0/config_ref_images.md.html#Icons%20and%20Splash%20Screens


   The size for each should be:

   xlarge (xhdpi): at least 960 × 720
   large (hdpi): at least 640 × 480
   medium (mdpi): at least 470 × 320
   small (ldpi): at least 426 × 320
   Make sure you have these in config.xml:

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

  then put copies of your splash screen image (each having the correct 
  resolution for the target platform) in the drawable* folders, like this:

   platforms/android/res/drawable/screen.png
   platforms/android/res/drawable-hdpi/screen.png
   platforms/android/res/drawable-ldpi/screen.png
   platforms/android/res/drawable-mdpi/screen.png
   platforms/android/res/drawable-xhdpi/screen.png

   Also, suggest removing this from your config file:

   <preference name="auto-hide-splash-screen" value="true" />