cordova/phonegap

cordova启动页面和图标的设置

2016-08-22  本文已影响3080人  lion1ou

原文地址

config.xml配置

在cordova5.0版本以后,需要安装cordova-plugin-splashscreen插件以后才能修改和设置App的启动页面。

安装splashscreen插件:

cordova plugin add cordova-plugin-splashscreen
或
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git

基本配置

然后在你的config.xml文件中,添加以下代码

<platform name="android">  
    <icon density="ldpi" src="res/icon/android/icon-36-ldpi.png" />  
    <icon density="mdpi" src="res/icon/android/icon-48-mdpi.png" />  
    <icon density="hdpi" src="res/icon/android/icon-72-hdpi.png" />  
    <icon density="xhdpi" src="res/icon/android/icon-96-xhdpi.png" />  
    <icon density="xxhdpi" src="res/icon/android/icon-144-xxhdpi.png" />  
    <icon density="xxxhdpi" src="res/icon/android/icon-192-xxxhdpi.png" />  

    <splash density="land-hdpi" src="res/screen/android/splash-land-hdpi.png" />  
    <splash density="land-ldpi" src="res/screen/android/splash-land-ldpi.png" />  
    <splash density="land-mdpi" src="res/screen/android/splash-land-mdpi.png" />  
    <splash density="land-xhdpi" src="res/screen/android/splash-land-xhdpi.png" />  
    <splash density="port-hdpi" src="res/screen/android/splash-port-hdpi.png" />  
    <splash density="port-ldpi" src="res/screen/android/splash-port-ldpi.png" />  
    <splash density="port-mdpi" src="res/screen/android/splash-port-mdpi.png" />  
    <splash density="port-xhdpi" src="res/screen/android/splash-port-xhdpi.png" />  
</platform>  
<platform name="ios">  
    <!-- iOS 8.0+ -->  
    <!-- iPhone 6 Plus  -->  
    <icon src="res/icon/ios/icon-60@3x.png" width="180" height="180" />  
    <!-- iOS 7.0+ -->  
    <!-- iPhone / iPod Touch  -->  
    <icon src="res/icon/ios/icon-60.png" width="60" height="60" />  
    <icon src="res/icon/ios/icon-60@2x.png" width="120" height="120" />  
    <!-- iPad -->  
    <icon src="res/icon/ios/icon-76.png" width="76" height="76" />  
    <icon src="res/icon/ios/icon-76@2x.png" width="152" height="152" />  
    <!-- iOS 6.1 -->  
    <!-- Spotlight Icon -->  
    <icon src="res/icon/ios/icon-40.png" width="40" height="40" />  
    <icon src="res/icon/ios/icon-40@2x.png" width="80" height="80" />  
    <!-- iPhone / iPod Touch -->  
    <icon src="res/icon/ios/icon.png" width="57" height="57" />  
    <icon src="res/icon/ios/icon@2x.png" width="114" height="114" />  
    <!-- iPad -->  
    <icon src="res/icon/ios/icon-72.png" width="72" height="72" />  
    <icon src="res/icon/ios/icon-72@2x.png" width="144" height="144" />  
    <!-- iPhone Spotlight and Settings Icon -->  
    <icon src="res/icon/ios/icon-small.png" width="29" height="29" />  
    <icon src="res/icon/ios/icon-small@2x.png" width="58" height="58" />  
    <icon src="res/icon/ios/icon-small@3x.png" width="87" height="87" />  
    <!-- iPad Spotlight and Settings Icon -->  
    <icon src="res/icon/ios/icon-50.png" width="50" height="50" />  
    <icon src="res/icon/ios/icon-50@2x.png" width="100" height="100" />  


    <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>

其他配置

图标文件夹内容

根据上面的配置信息,你需要准备好你自己的app图标和启动画面png文件:

存放路径不是以www文件夹为依据,而是以当前项目文件夹为依据

projectRoot
    hooks
    platforms
    plugins
    www
        css
        img
        js
    res
        screen
            android
            ios
        icon
            android
            ios

应用程序图标

应用程序启动页面

上一篇下一篇

猜你喜欢

热点阅读