首页 > 其他分享 >Cordova官方插件 -- Icon + SplashScreen

Cordova官方插件 -- Icon + SplashScreen

时间:2023-02-01 12:32:00浏览次数:51  
标签:插件 plugin -- 渐变 default 闪屏 Cordova true splashscreen


Cordova快速添加Icon图标和Splash闪屏页

官方Configuring Icons in the CLI文档

  图标的配置仅需在项目的config.xml文件中添加文件路径即可.

官方cordova-plugin-splashscreen文档

  1. 安装插件(命令行的两种方式)
  • cordova plugin add cordova-plugin-splashscreen
  • cordova plugin add https://github.com/apache/cordova-plugin-splashscreen.git
  1. 在项目第一级目录(与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/[email protected]" 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/[email protected]" width="120" height="120" />
<!-- iPad -->
<icon src="res/ios/icon-76.png" width="76" height="76" />
<icon src="res/ios/[email protected]" width="152" height="152" />
<!-- iOS 6.1 -->
<!-- Spotlight Icon -->
<icon src="res/ios/icon-40.png" width="40" height="40" />
<icon src="res/ios/[email protected]" width="80" height="80" />
<!-- iPhone / iPod Touch -->
<icon src="res/ios/icon.png" width="57" height="57" />
<icon src="res/ios/[email protected]" width="114" height="114" />
<!-- iPad -->
<icon src="res/ios/icon-72.png" width="72" height="72" />
<icon src="res/ios/[email protected]" width="144" height="144" />
<!-- iPhone Spotlight and Settings Icon -->
<icon src="res/ios/icon-small.png" width="29" height="29" />
<icon src="res/ios/[email protected]" width="58" height="58" />
<!-- iPad Spotlight and Settings Icon -->
<icon src="res/ios/icon-50.png" width="50" height="50" />
<icon src="res/ios/[email protected]" 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_闪屏页显示配置
  1. AutoHideSplashScreen(default-true):true为闪屏页显示结束时,自动隐藏.
    ​​​<preference name="AutoHideSplashScreen" value="true|false" />​
  2. SplashScreenDelay(default-3000):控制闪屏页的显示时长.
    ​​​<preference name="SplashScreenDelay" value="3000" />​
  3. SplashMaintainAspectRatio:false为拉伸闪屏页以适应屏幕宽高.
    ​​​<preference name="SplashMaintainAspectRatio" value="true|false" />​
  4. SplashShowOnlyFirstTime(default-true):true为仅第一次进入APP才显示闪屏页.
    ​​​<preference name="SplashShowOnlyFirstTime" value="true|false" />​
  5. FadeSplashScreen(default-true):true为允许使用渐变动画来隐藏闪屏页.
    ​​​<preference name="FadeSplashScreen" value="true|false"/>​
  6. FadeSplashScreenDuration(default-3000):闪屏页结束前value时间内开始渐变动画.
    ​​​<preference name="FadeSplashScreenDuration" value="3000"/>​
  7. ShowSplashScreenSpinner (default-true):true为闪屏页显示的时候,同时也会显示进度条Bar.
    ​​​<preference name="ShowSplashScreenSpinner" value="true|false"/>​
  1. 在JS中可做如下配置
  • 显示闪屏页
navigator.splashscreen.show();
  • 隐藏闪屏页
  • A-渐变隐藏
window.setTimeout(function () {
navigator.splashscreen.hide();
}, splashDuration - fadeDuration);
// 闪屏页显示时长 - 渐变时长 = 闪屏开始渐变隐藏的时刻
  • B-直接隐藏
navigator.splashscreen.hide();


标签:插件,plugin,--,渐变,default,闪屏,Cordova,true,splashscreen
From: https://blog.51cto.com/u_15950249/6031355

相关文章

  • ListView - 仿照IOS拉到上下底部仍可继续拉并自动回弹
    PART_ONLY自定义类继承​​ListView​​,覆写​​overScrollBy()​​publicclassCListViewextendsListView{privatestaticfinalintMAX_OVERSCROLLY_DISTANCE......
  • Android中Java和JS调用对方方法的简介
    AJava调用Js的方法无参:使用WebView控件​​loadUrl()​​方法,传入​​"javascript:jsMethod()"​​即可调用​​jsMethod()​​方法带参:同上,并将参数加上即可​​"java......
  • 自定义 CircleView - 继承 View 重写 onDraw
    一、画一个圆形的View如图,该圆形控件的宽为match_parent,高150dp,为了看到控件的整体宽高效果,为控件加了背景色即浅绿色:#3300aa00该页面的布局<?xmlversion="1.0"encodi......
  • Spring Native打包本地镜像,无需通过Graal的maven插件buildtools
    简介在文章《GraalVM和SpringNative尝鲜,一步步让Springboot启动飞起来,66ms完成启动》中,我们介绍了如何使用SpringNative和buildtools插件,打包出本地镜像,也打包成Docker......
  • 读Java8函数式编程笔记07_设计和架构的原则
    1. SOLID原则1.1. 开发良好面向对象程序的准则1.2. Liskovsubstitution里氏替换1.3. Interfacesegregation接口隔离1.4. Singleresponsibility单一功能原则1......
  • 并发编程-Python
    目录01、理论多道技术null02、进程进程运行的三状态图同步和异步阻塞和非阻塞开启进程的两种方式进程对象的join方法进程之间数据相互隔离(默认情况下)进程对象及其他方法僵......
  • 开源大数据分析平台的内容有什么?
    在大数据时代,做好数据管理是非常重要的一个步骤。可以给企业做出正确的经营决策,指引新的发展方向。因此,随着数字化时代的到来,很多企业都倾向于寻找适宜的开源大数据分析平......
  • 开源数据湖仓:Delta vs. Iceberg vs. Hudi vs. Kudu vs. Hologres
    深度对比Delta、Iceberg和Hudi三大开源数据湖方案_开源_胡争(子毅)_InfoQ精选文章https://www.infoq.cn/article/fjebconxd2sz9wloykfo替换Kudu,Hologres助力好未来网校实......
  • 博客园-显示公式-测试
    1-博客园设置首先设置博客园参数:博客园后台-选项-启用数学公式支持2-显示公式//这是公式的文本。将公式用LaTex表示(可用软件生成),之后在前后加“$”,最后将文本插入博客......
  • CodeForces 607B Zuma
    CF607BZumalink洛谷linkCodeForces题意Genos最近在他的手机上下载了祖玛游戏。在祖玛游戏里,存在\(n\)个一行的宝石,第\(i\)个宝石的颜色是\(C_i\)。这个游戏......