Cordova官方插件 -- Icon + SplashScreen
来源:互联网 发布:vr眼镜评测 知乎 编辑:程序博客网 时间:2024/06/05 11:46
Cordova快速添加Icon图标和Splash闪屏页
官方Configuring Icons in the CLI文档
图标的配置仅需在项目的config.xml文件中添加文件路径即可.
官方cordova-plugin-splashscreen文档
安装插件(两种方式)
cordova plugin add cordova-plugin-splashscreen
cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git
在项目第一级目录(与platform同级)的config.xml中做如下配置
A_添加各平台闪屏页文件的相对路径.
<platform name="android"> <!-- 图标 --> <icon src="res/screen/android/ic_launcher.png" density="ldpi" /> <icon src="res/screen/android/ic_launcher.png" density="mdpi" /> <icon src="res/screen/android/ic_launcher.png" density="hdpi" /> <icon src="res/screen/android/ic_launcher.png" density="xhdpi" /> <!-- 闪屏页 --> <splash src="res/screen/android/launch.png" density="land-hdpi"/> <splash src="res/screen/android/launch.png" density="land-ldpi"/> <splash src="res/screen/android/launch.png" density="land-mdpi"/> <splash src="res/screen/android/launch.png" density="land-xhdpi"/> <splash src="res/screen/android/launch.png" density="port-hdpi"/> <splash src="res/screen/android/launch.png" density="port-ldpi"/> <splash src="res/screen/android/launch.png" density="port-mdpi"/> <splash src="res/screen/android/launch.png" density="port-xhdpi"/></platform><platform name="ios"> <!-- 图标 --> <!-- iOS 8.0+ --> <!-- iPhone 6 Plus --> <icon src="res/ios/icon-60@3x.png" width="180" height="180" /> <!-- iOS 7.0+ --> <!-- iPhone / iPod Touch --> <icon src="res/ios/icon-60.png" width="60" height="60" /> <icon src="res/ios/icon-60@2x.png" width="120" height="120" /> <!-- iPad --> <icon src="res/ios/icon-76.png" width="76" height="76" /> <icon src="res/ios/icon-76@2x.png" width="152" height="152" /> <!-- iOS 6.1 --> <!-- Spotlight Icon --> <icon src="res/ios/icon-40.png" width="40" height="40" /> <icon src="res/ios/icon-40@2x.png" width="80" height="80" /> <!-- iPhone / iPod Touch --> <icon src="res/ios/icon.png" width="57" height="57" /> <icon src="res/ios/icon@2x.png" width="114" height="114" /> <!-- iPad --> <icon src="res/ios/icon-72.png" width="72" height="72" /> <icon src="res/ios/icon-72@2x.png" width="144" height="144" /> <!-- iPhone Spotlight and Settings Icon --> <icon src="res/ios/icon-small.png" width="29" height="29" /> <icon src="res/ios/icon-small@2x.png" width="58" height="58" /> <!-- iPad Spotlight and Settings Icon --> <icon src="res/ios/icon-50.png" width="50" height="50" /> <icon src="res/ios/icon-50@2x.png" width="100" height="100" /> <!-- 闪屏页 --> <splash src="res/screen/ios/Default~iphone.png" width="320" height="480"/> <splash src="res/screen/ios/Default@2x~iphone.png" width="640" height="960"/> <splash src="res/screen/ios/Default-Portrait~ipad.png" width="768" height="1024"/> <splash src="res/screen/ios/Default-Portrait@2x~ipad.png" width="1536" height="2048"/> <splash src="res/screen/ios/Default-Landscape~ipad.png" width="1024" height="768"/> <splash src="res/screen/ios/Default-Landscape@2x~ipad.png" width="2048" height="1536"/> <splash src="res/screen/ios/Default-568h@2x~iphone.png" width="640" height="1136"/> <splash src="res/screen/ios/Default-667h.png" width="750" height="1334"/> <splash src="res/screen/ios/Default-736h.png" width="1242" height="2208"/> <splash src="res/screen/ios/Default-Landscape-736h.png" width="2208" height="1242"/></platform><platform name="windows"> <splash src="res/screen/windows/splashscreen.png" width="620" height="300"/> <splash src="res/screen/windows/splashscreenphone.png" width="1152" height="1920"/></platform><platform name="blackberry10"> <rim:splash src="res/screen/blackberry/splashscreen.png"/></platform>
B_闪屏页显示配置
AutoHideSplashScreen(default-true):true为闪屏页显示结束时,自动隐藏.
<preference name="AutoHideSplashScreen" value="true|false" />
SplashScreenDelay(default-3000):控制闪屏页的显示时长.<preference name="SplashScreenDelay" value="3000" />
SplashMaintainAspectRatio:false为拉伸闪屏页以适应屏幕宽高.<preference name="SplashMaintainAspectRatio" value="true|false" />
SplashShowOnlyFirstTime(default-true):true为仅第一次进入APP才显示闪屏页.<preference name="SplashShowOnlyFirstTime" value="true|false" />
FadeSplashScreen(default-true):true为允许使用渐变动画来隐藏闪屏页.<preference name="FadeSplashScreen" value="true|false"/>
FadeSplashScreenDuration(default-3000):闪屏页结束前value时间内开始渐变动画.<preference name="FadeSplashScreenDuration" value="3000"/>
ShowSplashScreenSpinner (default-true):true为闪屏页显示的时候,同时也会显示进度条Bar.<preference name="ShowSplashScreenSpinner" value="true|false"/>
在JS中可做如下配置
显示闪屏页
navigator.splashscreen.show();
隐藏闪屏页
A-渐变隐藏
window.setTimeout(function () { navigator.splashscreen.hide();}, splashDuration - fadeDuration);// 闪屏页显示时长 - 渐变时长 = 闪屏开始渐变隐藏的时刻
B-直接隐藏
navigator.splashscreen.hide();
以上。如有错误和疑问,欢迎指正提出。 catface.wyh@gmail.com
- Cordova官方插件 -- Icon + SplashScreen
- cordova splashscreen插件
- ionic添加cordova插件-Splashscreen
- cordova-plugin-splashscreen插件使用时显示OOM
- Cordova安装官方插件
- Cordova 3.x 基础(2) -- 应用图标icon和启动页面SplashScreen
- cordova SplashScreen插件在android上退出app后不再显示启动画面的问题
- phonegap+splashscreen插件
- Cordova官方插件 -- Vibration、Media、NativeAudio
- SplashScreen
- Cordova插件
- cordova插件
- cordova插件
- Changing the Cordova app icon
- WindowsVista的官方ICON
- Cordova-----3、Cordova使用插件
- Cordova-----4、Cordova自定义插件
- admob cordova插件 / cordova admob 插件 教程
- Android 实用工具Hierarchy Viewer实战
- 大数加法
- 单例模式的七种写法(实际五种写法)
- CentOS下安装JDK
- 实现10个数排列
- Cordova官方插件 -- Icon + SplashScreen
- Android Intent传值反馈,向后传递,要求返回的传值
- SecureCRT 常用命令
- 解决svn一直报Error validating server certificate for https://XXXX fingerprint
- 计算机知识-编程语言对比
- 关于运算符重载的两种方式的优缺点比较
- SGU 299 Triangle(大数)
- Python excel转xml
- 最大子数组问题-GoLang实现