我一直在尝试为我的Ionic App添加闪屏
使用此配置,图标确实有效,但splashscreen
无效。它显示的是空白屏幕,甚至不是cordova
默认splashscreen.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.toggle423609" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Toggle</name>
<description>
An Ionic Framework and Cordova project.
</description>
<author email="you@example.com" href="http://example.com.com/">
Your Name Here
</author>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="android-minSdkVersion" value="16"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="3000"/>
<preference name="AutoHideSplashScreen" value="false" />
<feature name="StatusBar">
<param name="ios-package" value="CDVStatusBar" onload="true"/>
</feature>
<platform name="android">
<icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/>
<icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/>
<icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/>
<icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/>
<icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/>
<icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
<splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/>
<splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/>
<splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/>
<splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/>
<splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/>
<splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/>
<splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/>
<splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/>
<splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/>
<splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
<splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
<splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
</platform>
<platform name="ios">
<icon src="resources/ios/icon/icon.png" width="57" height="57"/>
<icon src="resources/ios/icon/icon@2x.png" width="114" height="114"/>
<icon src="resources/ios/icon/icon-40.png" width="40" height="40"/>
<icon src="resources/ios/icon/icon-40@2x.png" width="80" height="80"/>
<icon src="resources/ios/icon/icon-50.png" width="50" height="50"/>
<icon src="resources/ios/icon/icon-50@2x.png" width="100" height="100"/>
<icon src="resources/ios/icon/icon-60.png" width="60" height="60"/>
<icon src="resources/ios/icon/icon-60@2x.png" width="120" height="120"/>
<icon src="resources/ios/icon/icon-60@3x.png" width="180" height="180"/>
<icon src="resources/ios/icon/icon-72.png" width="72" height="72"/>
<icon src="resources/ios/icon/icon-72@2x.png" width="144" height="144"/>
<icon src="resources/ios/icon/icon-76.png" width="76" height="76"/>
<icon src="resources/ios/icon/icon-76@2x.png" width="152" height="152"/>
<icon src="resources/ios/icon/icon-small.png" width="29" height="29"/>
<icon src="resources/ios/icon/icon-small@2x.png" width="58" height="58"/>
<icon src="resources/ios/icon/icon-small@3x.png" width="87" height="87"/>
<splash src="resources/ios/splash/Default-568h@2x~iphone.png" height="1136" width="640"/>
<splash src="resources/ios/splash/Default-667h.png" height="1334" width="750"/>
<splash src="resources/ios/splash/Default-736h.png" height="2208" width="1242"/>
<splash src="resources/ios/splash/Default-Landscape-736h.png" height="1242" width="2208"/>
<splash src="resources/ios/splash/Default-Landscape@2x~ipad.png" height="1536" width="2048"/>
<splash src="resources/ios/splash/Default-Landscape~ipad.png" height="768" width="1024"/>
<splash src="resources/ios/splash/Default-Portrait@2x~ipad.png" height="2048" width="1536"/>
<splash src="resources/ios/splash/Default-Portrait~ipad.png" height="1024" width="768"/>
<splash src="resources/ios/splash/Default@2x~iphone.png" height="960" width="640"/>
<splash src="resources/ios/splash/Default~iphone.png" height="480" width="320"/>
</platform>
</widget>
答案 0 :(得分:20)
首先尝试读取您的插件:
$ ionic plugin remove cordova-plugin-splashscreen
$ ionic plugin add cordova-plugin-splashscreen
splash
文件夹中的resources
图片。$ ionic resources --splash
$ ionic build android
并运行您的应用检查Ionic documentation - Icon and Splash Screen Image Generation
如果这不起作用,您应该删除并读取遇到问题的平台。
$ cordova platform remove android (or ios)
$ cordova platform add android (or ios)
答案 1 :(得分:11)
这是你的回答!!
如果您使用Cordova 6.4.0(在终端中点击cordova -v
查看版本),您将面临此问题(构建后不会生成图标和启动画面)
要解决此问题,您有两种选择:
<icon src="resources\android\icon\drawable-ldpi-icon.png" qualifier="ldpi"/>
代替<icon src="resources\android\icon\drawable-ldpi-icon.png" density="ldpi"/>
。建立项目。会工作。
npm install -g cordova@6.3.1
即可安装cordova版本6.3.1。删除然后添加平台,进一步构建它。像魅力一样......。问候!! :P
答案 2 :(得分:6)
删除后添加cordova
$ cordova platform remove android (or ios)
$ cordova platform add android (or ios)
您将获得带有图标和启动画面的/res
文件夹。复制/res
中的内容并粘贴到platfomrs/android/res
,这将替换标准图标和启动画面。
然后构建您的应用程序,您将获得自定义图像。
我使用了离子标签模板,没有更改。
答案 3 :(得分:4)
自2016年11月7日起.Cordova 6.4.0发布了新的Android版本 - android@6.1.0。
你最有可能在你的cordova(或者旧版本的android)中使用android @ 5。 尝试更新/安装新版本的cordova android。
要升级: cordova平台更新android@6.1.0
明确添加: cordova平台添加android@6.1.0
https://cordova.apache.org/announcements/2016/11/07/android-release.html https://cordova.apache.org/blog/
答案 4 :(得分:4)
我的Splash-Screen也没出现(Ionic 3)。我发现这个Link非常有帮助。 config.xml
中的这些条目对我有用:
<preference name="SplashMaintainAspectRatio" value="true"/>
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="30000"/>
<preference name="AutoHideSplashScreen" value="false"/>
<preference name="SplashShowOnlyFirstTime" value="false"/>
<preference name="FadeSplashScreen" value="false"/>
答案 5 :(得分:1)
我们尝试使用以下配置系统更新离子应用程序的启动画面,但失败了:
Cordova CLI: 6.4.0
Ionic CLI Version: 2.1.7
Ionic App Lib Version: 2.1.4
ios-deploy version: 1.9.0
ios-sim version: 5.0.11
OS: macOS Sierra
Node Version: v6.9.1
Xcode version: Xcode 8.1 Build version 8B62
我们能够生成启动画面并在以下配置系统中解决问题:
Cordova CLI: 6.3.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 1.2.4
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Mac OS X El Capitan
Node Version: v6.6.0
Xcode version: Xcode 8.1 Build version 8B62
答案 6 :(得分:1)
我有同样的问题,我通过转到路径MY_PROJECT\platforms\android\res
并删除drawable*
和mipmap*
手动解决,然后从{{复制drawable*
和mipmap*
1}}然后再重新构建项目
答案 7 :(得分:0)
检查您是否有&#34; cordova-plugin-splashscreen&#34;已安装插件(在plugins/
文件夹中或通过运行ionic cordova plugins
(对于Ionic v3 +)或ionic plugins
命令(旧版本的Ionic)。
如果没有,请执行:
ionic plugin add cordova-plugin-splashscreen
(Ionic v1 - v2)
ionic cordova plugin add cordova-plugin-splashscreen
(Ionic v3 +)
如果没有插件,iOS仍会暂时显示启动画面,但Android不会。
答案 8 :(得分:0)
使用以下命令在您的应用中添加Splash Screen Cordova插件
$ionic cordova plugin add cordova-plugin-splashscreen
$npm install --save @ionic-native/splash-screen
在 config.xml 文件
中添加以下行<preference name="FadeSplashScreen" value="false" />
<preference name="AutoHideSplashScreen" value="false" />
此外,在 app.component.ts 文件中删除SplashScreen.hide()
更多详细信息,请访问示例:https://answerdone.blogspot.com/2018/02/ionic-3-splash-screen-plugins.html