cordova啟動(dòng)頁面和圖標(biāo)的設(shè)置

原文地址

config.xml配置

在cordova5.0版本以后,需要安裝cordova-plugin-splashscreen插件以后才能修改和設(shè)置App的啟動(dòng)頁面。

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

其他配置

  • 自動(dòng)隱藏啟動(dòng)頁面AutoHideSplashScreen(默認(rèn)為:true)

      <preference name="AutoHideSplashScreen" value="true" />
    
  • 顯示啟動(dòng)頁面的時(shí)間長度SplashScreenDelay(默認(rèn)為:3000)

      <preference name="SplashScreenDelay" value="3000" />
    

    若想禁用啟動(dòng)頁面,可設(shè)置為:<preference name="SplashScreenDelay" value="0"/>

    如果是iOS平臺(tái)上想禁止啟動(dòng)頁面,還需要添加<preference name="FadeSplashScreenDuration" value="0"/>

  • 啟動(dòng)頁面淡入淡出的效果

    是否顯示淡入淡出效果FadeSplashScreen(默認(rèn)為:true)

      <preference name="FadeSplashScreen" value="false"/>
    

    淡入淡出效果的執(zhí)行時(shí)間長度FadeSplashScreenDuration(默認(rèn)為:500)

      <preference name="FadeSplashScreenDuration" value="750"/>
    

    注意:FadeSplashScreenDuration時(shí)間是包含在SplashScreenDelay的時(shí)間里的。

  • 啟動(dòng)頁面是否允許旋轉(zhuǎn)(默認(rèn)為:true)

      <preference name="ShowSplashScreenSpinner" value="false"/>
    
  • 插件還可以通過js代碼調(diào)用,提供有以下兩個(gè)方法:

      navigator.splashscreen.hide();//隱藏啟動(dòng)頁面
    
      navigator.splashscreen.show();//顯示啟動(dòng)頁面
    
  • 在Android平臺(tái)下的特殊設(shè)置

      <preference name="SplashMaintainAspectRatio" value="true|false" />
      <preference name="SplashShowOnlyFirstTime" value="true|false" />
    

    SplashMaintainAspectRatio:選填項(xiàng),默認(rèn)為false。當(dāng)設(shè)置為true時(shí),則不會(huì)拉伸圖片來填充屏幕,會(huì)以圖片原始比例顯示圖片。

    SplashShowOnlyFirstTime:選填項(xiàng),默認(rèn)為true。當(dāng)設(shè)置為false時(shí),APP通過navigator.app.exitApp()代碼退出app后,在下次打開APP時(shí),還會(huì)顯示啟動(dòng)頁面。若為true時(shí),就不會(huì)出現(xiàn)。

圖標(biāo)文件夾內(nèi)容

根據(jù)上面的配置信息,你需要準(zhǔn)備好你自己的app圖標(biāo)和啟動(dòng)畫面png文件:

存放路徑不是以www文件夾為依據(jù),而是以當(dāng)前項(xiàng)目文件夾為依據(jù)

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

應(yīng)用程序圖標(biāo)

  • 安卓圖標(biāo)具體規(guī)格如下(存放目錄:res/icon/android/)

      36*36   icon-36-ldpi.png
      48*48   icon-48-ldpi.png
      72*72   icon-72-ldpi.png
      96*96   icon-96-ldpi.png
      144*144 icon-144-ldpi.png
      192*192 icon-192-ldpi.png
    
  • iOS圖標(biāo)具體規(guī)格如下(存放目錄:res/icon/ios/)

      29*29   icon-small.png
      58*58   icon-small@2x.png
      87*87   icon-small@3x.png
      40*40   icon-40.png
      80*80   icon-40@2x.png
      50*50   icon-50.png
      100*100 icon-50@2x.png
      60*60   icon-60.png
      120*120 icon-60@2x.png
      180*180 icon-60@3x.png
      72*72   icon-72.png
      144*144 icon-72@2x.png
      76*76   icon-76.png
      152*152 icon-76@2x.png
    

應(yīng)用程序啟動(dòng)頁面

  • 安卓啟動(dòng)畫面具體規(guī)格如下(存放目錄:res/screen/android/)

      960*720 splash-land-xhdpi.png
      640*480 splash-land-hdpi.png
      470*320 splash-land-mdpi.png
      426*320 splash-land-ldpi.png
      720*960 splash-port-xhdpi.png
      480*640 splash-port-hdpi.png
      320*470 splash-port-mdpi.png
      320*426 splash-port-ldpi.png
    
  • iOS啟動(dòng)畫面具體規(guī)格如下(存放目錄:res/screen/ios/)

      320*480 Default~iphone.png
      640*960 Default@2x~iphone.png
      768*1024    Default-Portrait~ipad.png
      1536*2048   Default-Portrait@2x~ipad.png
      1024*768    Default-Landscape~ipad.png
      2048*1536   Default-Landscape@2x~ipad.png
      640*1136    Default-568h@2x~iphone.png
      750*1334    Default-667h.png
      1242*2208   Default-736h.png
      2208*1242   Default-Landscape-736h.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,461評(píng)論 6 532
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 98,538評(píng)論 3 417
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 176,423評(píng)論 0 375
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 62,991評(píng)論 1 312
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 71,761評(píng)論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 55,207評(píng)論 1 324
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,268評(píng)論 3 441
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 42,419評(píng)論 0 288
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 48,959評(píng)論 1 335
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 40,782評(píng)論 3 354
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 42,983評(píng)論 1 369
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,528評(píng)論 5 359
  • 正文 年R本政府宣布,位于F島的核電站,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 44,222評(píng)論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,653評(píng)論 0 26
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,901評(píng)論 1 286
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 51,678評(píng)論 3 392
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 47,978評(píng)論 2 374

推薦閱讀更多精彩內(nèi)容