电话间隙闪屏插件不显示图像
Posted
技术标签:
【中文标题】电话间隙闪屏插件不显示图像【英文标题】:phone gap splashscreen plugin is not displaying image 【发布时间】:2018-07-16 09:14:40 【问题描述】:我正在使用科尔多瓦闪屏插件,由于某种原因,图像没有显示,它在代码中指定的秒数内显示了闪屏,但没有显示确切的图像
这是一个屏幕截图:
我尝试将图像添加到多个来源(一次在主文件夹中,一次在 www 文件夹中,尝试将所有图像添加到可绘制文件夹,如果这是已知的事情,也尝试过 https://pgicons.abiro.com/ 及其 xml文件同样的问题)
这里是我的 xml 代码
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.helloworld" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<platform name="android">
<!-- you can use any density that exists in the Android project
<splash src="splash.png" />
-->
<splash src="www/res/screen/android/ldpi.png" density="land-ldpi" />
<splash src="www/res/screen/android/mdpi.png" density="land-mdpi" />
<splash src="www/res/screen/android/hdpi.png" density="land-hdpi"/>
<splash src="www/res/screen/android/xhdpi.png" density="land-xhdpi" />
<splash src="www/res/screen/android/xxhdpi.png" density="land-xxhdpi" />
<platform name="ios">
<splash platform="ios" src="www/res/screen/ios/320x480.png" />
<splash platform="ios" src="www/res/screen/ios/640x960.png" />
<splash platform="ios" src="www/res/screen/ios/768x1024.png" />
<splash platform="ios" src="www/res/screen/ios/1536x2048.png" />
<splash platform="ios" src="www/res/screen/ios/640x1136.png" />
<splash platform="ios" src="www/res/screen/ios/750x1334.png" />
<splash platform="ios" src="www/res/screen/ios/2208x1242.png" />
<splash platform="ios" src="www/res/screen/ios/1242x2208.png" />
</platform>
<platform name="browser">
<preference name="SplashScreen" value="screen.png" /> <!-- defaults to "/img/logo.png" -->
<preference name="SplashScreenWidth" value="600" /> <!-- defaults to "170" -->
<preference name="SplashScreenHeight" value="300" /> <!-- defaults to "200" -->
</platform>
</platform>
<preference name="SplashScreen" value="screen"/>
<preference name="SplashScreenDelay" value="5000" />
<name>Project</name>
<description>
A blank PhoneGap app.
</description>
<author email="support@phonegap.com" href="http://phonegap.com">
PhoneGap Team
</author>
<content src="index.html" />
<access origin="*" />
</widget>
这里是https://pgicons.abiro.com/生成的xml代码
<?xml version='1.0' encoding='utf-8'?>
<widget xmlns="http://www.w3.org/ns/widgets">
<splash src="splash.png" />
<platform name="ios">
<icon src="res/icon/ios/icon-1024.png" />
<icon src="res/icon/ios/icon-small.png" />
<icon src="res/icon/ios/icon-small@2x.png" />
<icon src="res/icon/ios/icon-small@3x.png" />
<icon src="res/icon/ios/icon-small-40.png" />
<icon src="res/icon/ios/icon-small-40@2x.png" />
<icon src="res/icon/ios/icon-small-40@3x.png" />
<icon src="res/icon/ios/icon-small-50.png" />
<icon src="res/icon/ios/icon-small-50@2x.png" />
<icon src="res/icon/ios/icon.png" />
<icon src="res/icon/ios/icon@2x.png" />
<icon src="res/icon/ios/icon-60.png" />
<icon src="res/icon/ios/icon-60@2x.png" />
<icon src="res/icon/ios/icon-60@3x.png" />
<icon src="res/icon/ios/icon-72.png" />
<icon src="res/icon/ios/icon-72@2x.png" />
<icon src="res/icon/ios/icon-76.png" />
<icon src="res/icon/ios/icon-76@2x.png" />
<icon src="res/icon/ios/icon-167.png" />
<icon src="res/icon/ios/icon-83.5@2x.png" />
<splash src="res/screen/ios/Default@2x~iphone~anyany.png" />
<splash src="res/screen/ios/Default@2x~iphone~comany.png" />
<splash src="res/screen/ios/Default@3x~iphone~anyany.png" />
<splash src="res/screen/ios/Default@3x~iphone~comany.png" />
<splash src="res/screen/ios/Default@2x~ipad~anyany.png" />
<splash src="res/screen/ios/Default@2x~ipad~comany.png" />
</platform>
<platform name="android">
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="SplashShowOnlyFirstTime" value="true" />
<icon density="ldpi" src="res/icon/android/ldpi.png" />
<icon density="mdpi" src="res/icon/android/mdpi.png" />
<icon density="hdpi" src="res/icon/android/hdpi.png" />
<icon density="xhdpi" src="res/icon/android/xhdpi.png" />
<icon density="xxhdpi" src="res/icon/android/xxhdpi.png" />
<icon density="xxxhdpi" src="res/icon/android/xxxhdpi.png" />
<splash density="port-ldpi" src="res/screen/android/splash-port-ldpi.png" />
<splash density="port-mdpi" src="res/screen/android/splash-port-mdpi.png" />
<splash density="port-hdpi" src="res/screen/android/splash-port-hdpi.png" />
<splash density="port-xhdpi" src="res/screen/android/splash-port-xhdpi.png" />
<splash density="port-xxhdpi" src="res/screen/android/splash-port-xxhdpi.png" />
<splash density="port-xxxhdpi" src="res/screen/android/splash-port-xxxhdpi.png" />
<splash density="port-ldpi" src="www/res/drawable-port-ldpi/splash-port-ldpi.png" />
<splash density="port-mdpi" src="www/res/drawable-port-mdpi/splash-port-mdpi.png" />
<splash density="port-hdpi" src="www/res/drawable-port-hdpi/splash-port-hdpi.png" />
<splash density="port-xhdpi" src="www/res/drawable-port-xhdpi/splash-port-xhdpi.png" />
<splash density="port-xxhdpi" src="www/res/drawable-port-xxhdpi/splash-port-xxhdpi.png" />
<splash density="port-xxxhdpi" src="www/res/drawable-port-xxxhdpi/splash-port-xxxhdpi.png" />
</platform>
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="5000" />
<name>Splash screen Project</name>
<description>
A PhoneGap app to test splash screen.
</description>
<author>
Sara
</author>
</widget>
这是项目文件夹和图像源的屏幕截图
我的配置:
pgicons 配置:
这里是两个项目的 indx.html 代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>current location</title>
<script type="text/javascript" charset="utf-8">
</script>
</head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<body>
<h1>hello</h1>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
</body>
</html>
我已经使用终端添加了平台(cordova platform add android)我已经尝试删除平台并再次添加它们 该插件也是使用终端添加的,尝试将其删除并再次添加它不起作用 我使用 phonegap 本地主机/bluestacks android 模拟器检查/我还尝试使用 adobe phonegap build 并使用 bluestacks 测试应用程序。该图标工作正常,它只是启动屏幕
如果您需要我添加任何详细信息,请随时询问 我被困在这里一周了,我被分配在两天内完成它:(
【问题讨论】:
尝试删除 www/ 部分,然后看看它是否有效 @Mart 我试过了,还是一样的不显示 【参考方案1】:我已经解决了这个问题,更新了启动插件行后
来自
<plugin name="cordova-plugin-splashscreen" source="npm" />
到
<plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
添加规范后它工作了
【讨论】:
以上是关于电话间隙闪屏插件不显示图像的主要内容,如果未能解决你的问题,请参考以下文章