zoukankan      html  css  js  c++  java
  • Splashscreen

    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);
  • 相关阅读:
    libyuv编译(各平台)【转】
    /dev/mem可没那么简单【转】
    嵌入式Linux上通过boa服务器实现cgi/html的web上网【转】
    linux select函数详解【转】
    dpkg: error processing package bluez (--configure) 解决方法【转】
    Linux内核中的中断栈与内核栈的补充说明【转】
    Linux内核中断引入用户空间(异步通知机制)【转】
    用户空间与内核空间,进程上下文与中断上下文[总结]【转】
    linux 路由表设置 之 route 指令详解【转】
    自己动手做聊天机器人 一-涉及知识【转】
  • 原文地址:https://www.cnblogs.com/tdalcn/p/3491922.html
Copyright © 2011-2022 走看看