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

155957_XF14_778987.png

安装完之后你发现项目多了点东西比如

160107_WHsI_778987.png

仔细观察下项目的目录结构,你会发现

160326_d545_778987.png

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

161527_iWa4_778987.png


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

对应这个设置,如果我们首次进入首页会比较慢,比如首页指定的是非本地的html,指定的是一个网络地址的文件,我们可以考虑将value设置为100000  也即是10秒。然后再在

设备准备好之后

执行navigator.splashscreen.hide(); 例子如下

var app = {
    // Application Constructor
    initialize: 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值