|
| 1 | +--- |
| 2 | +license: Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + or more contributor license agreements. See the NOTICE file |
| 4 | + distributed with this work for additional information |
| 5 | + regarding copyright ownership. The ASF licenses this file |
| 6 | + to you under the Apache License, Version 2.0 (the |
| 7 | + "License"); you may not use this file except in compliance |
| 8 | + with the License. You may obtain a copy of the License at |
| 9 | + |
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + |
| 12 | + Unless required by applicable law or agreed to in writing, |
| 13 | + software distributed under the License is distributed on an |
| 14 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + KIND, either express or implied. See the License for the |
| 16 | + specific language governing permissions and limitations |
| 17 | + under the License. |
| 18 | +--- |
| 19 | + |
| 20 | +# Icons and Splash Screens |
| 21 | + |
| 22 | +This section shows how to configure an app's icon and optional splash |
| 23 | +screen for various platforms, both when working in the Cordova CLI |
| 24 | +(described in The Command-Line Interface) or using platform-specific |
| 25 | +SDK tools (detailed in the Platform Guides). |
| 26 | + |
| 27 | +## Configuring Icons in the CLI |
| 28 | + |
| 29 | +When working in the CLI, icon source files are located within various |
| 30 | +platform-specific subdirectories within the project's `www/res/icons` |
| 31 | +directory. Newly created projects come with a default set of Cordova |
| 32 | +icons for you to replace for the platforms you wish to target. |
| 33 | + |
| 34 | +Android specifies icons for low, medium, high, and extra-high resolutions: |
| 35 | + |
| 36 | + android/icon-36-ldpi.png |
| 37 | + android/icon-48-mdpi.png |
| 38 | + android/icon-72-hdpi.png |
| 39 | + android/icon-96-xhdpi.png |
| 40 | + |
| 41 | +The iOS platform specifies 72-pixel-square icons for iPads, and |
| 42 | +57-pixel icons for iPhones and iPods, with high-resolution _2x_ |
| 43 | +variants for retina displays: |
| 44 | + |
| 45 | + ios/icon-57-2x.png |
| 46 | + ios/icon-57.png |
| 47 | + ios/icon-72-2x.png |
| 48 | + ios/icon-72.png |
| 49 | + |
| 50 | +Windows Phone specifies a default 48-pixel icon, along with various |
| 51 | +devices' background tiling images used when representing applications: |
| 52 | + |
| 53 | + windows-phone/icon-48.png |
| 54 | + windows-phone/icon-62-tile.png |
| 55 | + windows-phone/icon-173-tile.png |
| 56 | + |
| 57 | +Blackberry 10 requires an icon element in config.xml: |
| 58 | + |
| 59 | + <icon src="blackberry10/icon-86.png" /> |
| 60 | + |
| 61 | +See BlackBerry's documentation for targeting multiple sizes and locales. |
| 62 | + |
| 63 | +[http://developer.blackberry.com/html5/documentation/icon_element.html] |
| 64 | + |
| 65 | +Tizen requires an 128-pixel icon: |
| 66 | + |
| 67 | + tizen/icon-128.png |
| 68 | + |
| 69 | +## Configuring Splash Screens in the CLI |
| 70 | + |
| 71 | +Use the Splashscreen API to enable display of an app's introductory |
| 72 | +splash screen on many platforms. When working in the CLI, splash |
| 73 | +screen source files are located within the project's `www/res/screens` |
| 74 | +subdirectory. |
| 75 | + |
| 76 | +Android specifies both portrait- and landscape-oriented splash screen |
| 77 | +images for low, medium, high, and extra-high resolutions: |
| 78 | + |
| 79 | + android/screen-hdpi-landscape.png |
| 80 | + android/screen-hdpi-portrait.png |
| 81 | + android/screen-ldpi-landscape.png |
| 82 | + android/screen-ldpi-portrait.png |
| 83 | + android/screen-mdpi-landscape.png |
| 84 | + android/screen-mdpi-portrait.png |
| 85 | + android/screen-xhdpi-landscape.png |
| 86 | + android/screen-xhdpi-portrait.png |
| 87 | + |
| 88 | +The iOS platform specifies variants for iPhone/iPod and iPad, with |
| 89 | +variants for retina displays and different orientations. The _568h_ |
| 90 | +file applies to the iPhone 5's taller screen: |
| 91 | + |
| 92 | + ios/screen-ipad-landscape-2x.png |
| 93 | + ios/screen-ipad-landscape.png |
| 94 | + ios/screen-ipad-portrait-2x.png |
| 95 | + ios/screen-ipad-portrait.png |
| 96 | + ios/screen-iphone-landscape-2x.png |
| 97 | + ios/screen-iphone-landscape.png |
| 98 | + ios/screen-iphone-portrait-2x.png |
| 99 | + ios/screen-iphone-portrait.png |
| 100 | + ios/screen-iphone-portrait-568h-2x.png |
| 101 | + |
| 102 | +Windows Phone specifies a single splash screen image: |
| 103 | + |
| 104 | + windows-phone/screen-portrait.jpg |
| 105 | + |
| 106 | +The following sections detail how to set up splash screens when |
| 107 | +working with SDKs and related command-line tools described in Platform |
| 108 | +Guides. |
| 109 | + |
| 110 | +Don't forget to install the SplashScreen plugin before trying to use the |
| 111 | +`navigator.splashscreen.hide()` or `navigator.splashscreen.show()` methods. |
| 112 | + |
| 113 | +## Splash Screens for the Android Platform |
| 114 | + |
| 115 | +Place [9-patch image](https://developer.android.com/tools/help/draw9patch.html) |
| 116 | +files in the Android project's `platforms/android/res/drawable*` directories. |
| 117 | + |
| 118 | +The size for each should be: |
| 119 | + |
| 120 | +- xlarge (xhdpi): at least 960 × 720 |
| 121 | +- large (hdpi): at least 640 × 480 |
| 122 | +- medium (mdpi): at least 470 × 320 |
| 123 | +- small (ldpi): at least 426 × 320 |
| 124 | + |
| 125 | +When creating a new Android project, the default splash screen images |
| 126 | +provided in the Cordova sample app should already be present in the |
| 127 | +`platforms/android/res/drawable*` directories. Feel free to replace these |
| 128 | +with your own images. |
| 129 | +When providing your own splash screen images, you do not need to |
| 130 | +provide the same permutation of 8 as the Cordova default ones |
| 131 | +here. More or less optimization can be used. |
| 132 | +The `drawable` directory names must follow the Android conventions for |
| 133 | +supporting |
| 134 | +[screen sizes](http://developer.android.com/guide/practices/screens_support.html) and |
| 135 | +[alternate resources](http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources). |
| 136 | + |
| 137 | +In the top-level `config.xml` file (not the one in `platforms`), add the |
| 138 | +following preferences: |
| 139 | + |
| 140 | + <preference name="SplashScreen" value="screen" /> |
| 141 | + <preference name="SplashScreenDelay" value="10000" /> |
| 142 | + |
| 143 | +The first line sets the image to display as the splash screen. This is the |
| 144 | +file name of the png in the `drawable*` directories, minus the `.png` |
| 145 | +extension. The default value for SplashScreen is `screen` (for the file |
| 146 | +`platforms/android/res/drawable*/screen.png`), so if you |
| 147 | +name the image anything other than `screen.png` in the `drawable*` directories, |
| 148 | +you need to add/modify this line. |
| 149 | + |
| 150 | +The second line sets the default delay of how long the splashscreen appears in |
| 151 | +milliseconds. This should be the worst-case expected start time. |
| 152 | +The default value for SplashScreenDelay is 3000 ms. |
| 153 | + |
| 154 | +Finally, as a best practice, the splash screen should be present only as long |
| 155 | +as necessary. When your app has started and the webview has loaded, your app |
| 156 | +should hide the splash screen so that your main view is visible as soon as it |
| 157 | +is ready. Because the app start time will vary quite a bit due to a number of |
| 158 | +factors such as CPU speed and network, it is recommended that your app |
| 159 | +explicitly invoke `navigator.splashscreen.hide()` in the JavaScript |
| 160 | +method that responds to the `deviceready` event. Otherwise the splash screen |
| 161 | +will be visible for the SplashScreenDelay value that you configured above, |
| 162 | +which is likely longer than necessary. |
| 163 | +This event-driven approach is highly recommended versus having the splash |
| 164 | +screen visible for always a fixed duration. |
| 165 | + |
| 166 | +## Splash Screens for the iOS Platform |
| 167 | + |
| 168 | +Copy splash screen images into the iOS project's `Resources/splash` |
| 169 | +directory. Only add those images for the devices you want to support, |
| 170 | +such as iPad or iPhone. The size of each image should be: |
| 171 | + |
| 172 | +- Default-568h@2x~iphone.png (640x1136 pixels) |
| 173 | +- Default-Landscape@2x~ipad.png (2048x1496 pixels) |
| 174 | +- Default-Landscape~ipad.png (1024x748 pixels) |
| 175 | +- Default-Portrait@2x~ipad.png (1536x2008 pixels) |
| 176 | +- Default-Portrait~ipad.png (768x1004 pixels) |
| 177 | +- Default@2x~iphone.png (640x960 pixels) |
| 178 | +- Default~iphone.png (320x480 pixels) |
| 179 | + |
| 180 | +## Splash Screens for the BlackBerry 10 Platform |
| 181 | + |
| 182 | +Add a rim:splash element to config.xml for each resolution and locale you wish |
| 183 | +to support: |
| 184 | + |
| 185 | +<http://developer.blackberry.com/html5/documentation/rim_splash_element.html> |
0 commit comments