Splashscreen

Enables developers to show/hide the application's splash screen.

Methods

Permissions

Android

app/res/xml/config.xml

<pluginname="SplashScreen"value="org.apache.cordova.SplashScreen"/>

iOS

Cordova.plist

    Add an entry under the Plugins dictionary -with the key "SplashScreen"and value "CDVSplashScreen". 
    New projects should already have this key.

Setup

Android

  1. Copy your splash screen image into the res/drawable directories of your Android project. The sizes of each image should be:

    • xlarge (xhdpi): at least 960 x 720
    • large (hdpi): at least 640 x 480
    • medium (mdpi): at least 470 x 320
    • small (ldpi): at least 426 x 320

    It is highly recommended that you use a 9-patch image for your splash screen.

  2. In the onCreate method of the class that extends DroidGap add the following two lines:

    super.setIntegerProperty("splashscreen", R.drawable.splash);
    super.loadUrl("file:///android_asset/www/index.html",10000);

    The first line 'super.setIntegerProperty' sets the image to be displayed as the splashscreen. If you have named your image anything other than splash.png you will have to modify this line. The second line is the normal 'super.loadUrl' line but it has a second parameter which is the timeout value for the splash screen. In this example the splash screen will display for 10 seconds. If you want to dismiss the splash screen once you get the "deviceready" event you should call the navigator.splashscreen.hide() method.

iOS

  1. Copy your splash screen images into the Resources/splash directory of your iOS project. Only add the images for the devices you want to support (iPad screen size or iPhone screen size). The sizes of each image should be:

    • Default-568h@2x~iphone.png (640x1136 pixels)
    • Default-Landscape@2x~ipad.png (2048x1496 pixels)
    • Default-Landscape~ipad.png (1024x748 pixels)
    • Default-Portrait@2x~ipad.png (1536x2008 pixels)
    • Default-Portrait~ipad.png (768x1004 pixels)
    • Default@2x~iphone.png (640x960 pixels)
    • Default~iphone.png (320x480 pixels)

show

Displays the splash screen.

navigator.splashscreen.show();

Description

navigator.splashscreen.show() displays the applications splash screen.

Supported Platforms

  • Android
  • iOS

Quick Example

navigator.splashscreen.show();

Full Example

<!DOCTYPE html>
<html>
  <head>
    <title>Splashscreen Example</title>     <scripttype="text/javascript"charset="utf-8"src="cordova-2.2.0.js"></script>
    <scripttype="text/javascript"charset="utf-8">     // Wait for Cordova to load
    //
    document.addEventListener("deviceready", onDeviceReady,false);     // Cordova is ready
    //
    function onDeviceReady(){
        navigator.splashscreen.show();
    }     </script>
  </head>
  <body>
    <h1>Example</h1>
  </body>
</html>

hide

Dismiss the splash screen.

navigator.splashscreen.hide();

Description

navigator.splashscreen.hide() dismisses the applications splash screen.

Supported Platforms

  • Android
  • iOS

Quick Example

navigator.splashscreen.hide();

Full Example

<!DOCTYPE html>
<html>
  <head>
    <title>Splashscreen Example</title>     <scripttype="text/javascript"charset="utf-8"src="cordova-2.2.0.js"></script>
    <scripttype="text/javascript"charset="utf-8">     // Wait for Cordova to load
    //
    document.addEventListener("deviceready", onDeviceReady,false);     // Cordova is ready
    //
    function onDeviceReady(){
        navigator.splashscreen.hide();
    }     </script>
  </head>
  <body>
    <h1>Example</h1>
  </body>
</html>

iOS Quirk

  1. In your Cordova.plist, you need to modify the value for "AutoHideSplashScreen” to false

  2. Then, if you want to delay hiding the splash screen for 2 seconds, you can do this in your deviceready event handler:

    setTimeout(function(){
        navigator.splashscreen.hide();
    },2000);

Splashscreen的更多相关文章

  1. Day 2:增加SplashScreen

    If you want to add just single image, then create a pic in the size of 480*800 and name it as Splash ...

  2. 设置 phoneGap/Cordova 3.4 应用程序启动动画闪屏 SplashScreen

    当Cordova 程序打包并安装到手机中后,我们会发现启动程序时,会有数秒的黑屏现象,常见的解决方法则是设置闪屏后面. 这里以 Android 程序为例,介绍Cordova设置启动画面的方法. 1. ...

  3. 我也来SplashScreen

    SplashScreen,就是平时我们说的溅射屏幕,任何一个做过客户端程序的coder应该对它都不陌生,因为它能提升用户体验,让软件看上去更美.SplashScreenForm通常进入程序时是打开,主 ...

  4. Unity-WIKI 之 SplashScreen

    组件功能 在屏幕上的一个启动画面消失,等待几秒钟(或等待用户输入),然后淡出,下一个场景加载. 组件源码 using UnityEngine; using System.Collections; // ...

  5. WPF:如何为程序添加splashScreen(初始屏幕)

    原文:http://www.cnblogs.com/chenxizhang/archive/2010/03/25/1694606.html 官网: https://msdn.microsoft.com ...

  6. [Phonegap+Sencha Touch] 移动开发36 Phonegap/Cordova项目的图标和启动画面(splashscreen)配置

    原文地址:http://blog.csdn.net/lovelyelfpop/article/details/40780111 Phonegap/Cordova项目中的config.xml文件.里面配 ...

  7. WPF如何为程序添加splashScreen(初始屏幕)

    一.考虑到大部分的splashscreen其实都只是一个图片,所以最简单的做法是,先导入一张图片,然后设置它的生成操作为“splash screen” 二.通过程序设置SplashScreen pub ...

  8. WFP loading 窗口显示 SplashScreen

    public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { Spl ...

  9. winform 使用SplashScreen窗口

    SplashScreen,就是平时我们说的溅射屏幕,任何一个做过客户端程序的coder应该对它都不陌生,因为它能提升用户体验,让软件看上去更美.SplashScreenForm通常进入程序时是打开,主 ...

随机推荐

  1. mysql explain用法和结果的含义(转)

    重点是第二种用法,需要深入的了解. 先看一个例子: mysql> explain select * from t_order; +----+-------------+---------+--- ...

  2. 添加mongodb支持

    最近花了些时间,将引擎的存储换成了mongodb. 私下,我觉得现有的存储机制极为落后.现在写数据的操作交由单独的进程完成,该进程兼当数据缓冲与持续化数据的责任.此次引擎的更换,只是简单的利用mong ...

  3. 三 JSP 技术

    一 JSP 概述 1. 本质:在 HTML 语言中混合 Java 程序代码,由服务器端 Java 语言引擎解释执行.其中,HTML 负责描述信息显示格式,JSP 负责描述处理逻辑. 2. JSP 代码 ...

  4. UVa 11039 - Building designing

    题目大意:n个绝对值各不相同的非0整数,选出尽量多的数,排成一个序列,使得正负号交替且绝对值递增. 分析:按照绝对值大小排一次序,然后扫描一次,顺便做个标记即可. #include<cstdio ...

  5. 移动开发中使用Onsen UI的笔记

    onsen var m_index = ons.bootstrap() 初始化框架 m_index 赋值 增加对象. m_index.value('getUser',{ // user:window. ...

  6. android中的空格及汉字的宽度

    在Android布局中进行使用到空格,以便实现文字的对齐.那么在Android中如何表示一个空格呢? 空格:  窄空格:  一个汉字宽度的空格:   [用两个空格(  )占一个汉字的宽度时,两个空格比 ...

  7. ztong上机3

    二.实验名称:数字图像处理matlab上机 三.实验学时:2学时 四.实验目的:(详细填写) 掌握几何变换 掌握插值 理解配准的概念 五.实验内容 (1)首先自己写一个对图像进行旋转和缩放的复合变换程 ...

  8. PHP实例开发(2)PHP通过mail()或Socket发邮件

    PHP通过mail()或Socket发邮件 1.PHP中发送邮件的方法 PHP发送邮件是“非常的简单” 因为他提供了mail()函数直接发送,但这也继 register globals 成为了对初学者 ...

  9. AXIOM解析XML 详细原理

    转自:http://warlaze.blog.sohu.com/58477971.html AXIOM Axis对象模型(AXIOM)是一个XML对象模型,设计用于提高XML处理期间的内存的使用率和性 ...

  10. [HAOI2012]音量调节

    题目描述 一个吉他手准备参加一场演出.他不喜欢在演出时始终使用同一个音量,所以他决定每一首歌之前他都需要改变一次音量.在演出开始之前,他已经做好一个列表,里面写着每首歌开始之前他想要改变的音量是多少. ...