Android splash 插件,cordova splashscreen插件在android平台的使用

先到插件网站找这个插件

然后找到了这个

通过命令行安装插件cordova plugin add cordova-plugin-splashscreen

738f3ce49f7831cee82a9d9e63db842d.png

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

f753f308ef2176448752dddf5ca538ac.png

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

6aa0f03e40dbddd229c5ecf28173379b.png

screen.png对应的就是欢迎页面。

你可以将自己的screen.png覆盖掉所有的,当然大小最好按照原来的各个尺寸。。

用eclipse运行一下。结果就ok了。

再说下插件的几个属性

SplashScreen (string). The resource name which is used for the displaying splash screen. Different platforms use values for this.

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.

SplashScreenDelay (number, default to 3000). Amount of time in milliseconds to wait before automatically hide splash screen.

在config.xml中可以配置

resourcename指定的是资源的文件名。假如我们这里不设置。

默认就是

为了做个测试,我在各个文件夹下添加了screen1.png

然后在config.xml中指定

再运行一下发现欢迎页面变成了screen1.png图片

099e85a1040c8e1bed2d1ea802f60cd4.png

对应这个设置,如果我们首次进入首页会比较慢,比如首页指定的是非本地的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();

},

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值