在config.XML中的Cordova Splash屏幕首选项名称

时间:2013-10-06 05:11:26

标签: cordova cordova-3

我已按照此页面http://cordova.apache.org/docs/en/3.1.0/cordova_splashscreen_splashscreen.md.html#Splashscreen中的说明测试了一个启动画面,它要求我将以下代码添加到配置中,但是后续不是有效的CML,因此当我构建时我得到了错误在它上面。

<preference name="splashscreen", "splash" />
<preference name="splashScreenDelay", 10000 />

我还尝试将首选项名称更改为有效的XML,如下所示,它构建成功但没有出错,但是一旦构建后,以下首选项也会自动从config.XML中删除

<preference name="splashscreen", value="splash" />
<preference name="splashScreenDelay", value="10000" />

是该样本的来源,以便我可以按照它来使我的启动画面工作

4 个答案:

答案 0 :(得分:3)

使用CLI安装时,功能如下所示:

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

文档说:

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

我使用了这个组合并且有效:

<preference name="splashscreen" value="splash" />
<preference name="splashScreenDelay" value="10000" />

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

答案 1 :(得分:3)

为了将来参考,上面的答案都是旧的。 Cordova 4.0对启动画面有本机支持,config.xml中的这个例子应该清楚说明:

<platform name="android">
    <!-- you can use any density that exists in the Android project -->
    <splash src="res/screen/android/splash-land-hdpi.png" density="land-hdpi"/>
    <splash src="res/screen/android/splash-land-ldpi.png" density="land-ldpi"/>
    <splash src="res/screen/android/splash-land-mdpi.png" density="land-mdpi"/>
    <splash src="res/screen/android/splash-land-xhdpi.png" density="land-xhdpi"/>

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

<platform name="ios">
    <!-- images are determined by width and height. The following are supported -->
    <splash src="res/screen/ios/Default~iphone.png" width="320" height="480"/>
    <splash src="res/screen/ios/Default@2x~iphone.png" width="640" height="960"/>
    <splash src="res/screen/ios/Default-Portrait~ipad.png" width="768" height="1024"/>
    <splash src="res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
    <splash src="res/screen/ios/Default-Landscape~ipad.png" width="1024" height="768"/>
    <splash src="res/screen/ios/Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
    <splash src="res/screen/ios/Default-568h@2x~iphone.png" width="640" height="1136"/>
    <splash src="res/screen/ios/Default-667h.png" width="750" height="1334"/>
    <splash src="res/screen/ios/Default-736h.png" width="1242" height="2208"/>
    <splash src="res/screen/ios/Default-Landscape-736h.png" width="2208" height="1242"/>
</platform>

答案 2 :(得分:2)

应该是:

<preference name="splashscreen" value="splash" />
<preference name="splashScreenDelay" value="10000" />

手机档文件通常非常狡猾......

答案 3 :(得分:0)

  

你可以简单地使用

<preference name="AutoHideSplashScreen" value="true" />
<preference name="SplashScreenDelay" value="5000" />

AutoHideSplashScreen is allow you to change splash delay time.its defauly TRUE.