cordova splashscreen插件在android平台的使用
先到插件網站找這個插件
插件網站地址?http://cordova.apache.org/plugins/
然后找到了這個
cordova-plugin-splashscreen?
插件 ?地址是https://www.npmjs.com/package/cordova-plugin-splashscreen
通過命令行安裝插件cordova plugin add cordova-plugin-splashscreen
安裝完之后你發現項目多了點東西比如
仔細觀察下項目的目錄結構,你會發現
screen.png對應的就是歡迎頁面。
你可以將自己的screen.png覆蓋掉所有的,當然大小最好按照原來的各個尺寸。。
用eclipse運行一下。結果就ok了。
再說下插件的幾個屬性
Preferences
config.xml
SplashScreen?(string). The resource name which is used for the displaying splash screen. Different platforms use values for this.
?<preference?name="SplashScreen"?value="resourcename"?/>AutoHideSplashScreen?(boolean, default to?true). Indicates wherether hide splash screen automatically or not. Splash screen hidden after amount of time specified in the?SplashScreenDelay?preference.
?<preference?name="AutoHideSplashScreen"?value="true"?/>SplashScreenDelay?(number, default to 3000). Amount of time in milliseconds to wait before automatically hide splash screen.
?<preference?name="SplashScreenDelay"?value="3000"?/>
?
在config.xml中可以配置
<preference?name="SplashScreen"?value="resourcename"?/>?resourcename指定的是資源的文件名。假如我們這里不設置。
默認就是
<preference?name="SplashScreen"?value="screen"?/>為了做個測試,我在各個文件夾下添加了screen1.png 然后在config.xml中指定 <preference?name="SplashScreen"?value="screen1"?/>再運行一下發現歡迎頁面變成了screen1.png圖片對應這個設置,如果我們首次進入首頁會比較慢,比如首頁指定的是非本地的html,指定的是一個網絡地址的文件,我們可以考慮將value設置為100000 ?也即是10秒。然后再在
設備準備好之后
執行navigator.splashscreen.hide(); 例子如下
var?app?=?{//?Application?Constructorinitialize:?function()?{this.bindEvents();},//?Bind?Event?Listeners////?Bind?any?events?that?are?required?on?startup.?Common?events?are://?'load',?'deviceready',?'offline',?and?'online'.bindEvents:?function()?{document.addEventListener('deviceready',?this.onDeviceReady,?false);},//?deviceready?Event?Handler////?The?scope?of?'this'?is?the?event.?In?order?to?call?the?'receivedEvent'//?function,?we?must?explicitly?call?'app.receivedEvent(...);'onDeviceReady:?function()?{//app.receivedEvent('deviceready');navigator.splashscreen.hide();},轉載于:https://my.oschina.net/liangzhenghui/blog/546845
總結
以上是生活随笔為你收集整理的cordova splashscreen插件在android平台的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql 5.7 多主一从_mysql
- 下一篇: jq 多个div从右向左依次显示_jqu