【问题标题】:How to display Splashscreen in Phonegap 3.3如何在 Phonegap 3.3 中显示启动画面
【发布时间】:2014-02-18 21:36:29
【问题描述】:

如何正确显示启动画面?我正在使用 CLi 本地构建,我听说它是​​兼容的。 我添加了插件:phonegap plugin add org.apache.cordova.splashscreen 这是我的配置文件:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.Snap.What" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
    <name>WhatSnap</name>
    <description>
        Hello World sample application that responds to the deviceready event.
    </description>
    <author email="support@phonegap.com" href="http://phonegap.com">
        PhoneGap Team
    </author>
    <feature name="http://api.phonegap.com/1.0/device" />
    <preference name="permissions" value="none" />
    <preference name="orientation" value="default" />
    <preference name="target-device" value="universal" />
    <preference name="fullscreen" value="true" />
    <preference name="webviewbounce" value="true" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="false" />
    <preference name="ios-statusbarstyle" value="black-opaque" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="show-splash-screen-spinner" value="true" />
    <preference name="auto-hide-splash-screen" value="true" />
    <preference name="disable-cursor" value="false" />
    <preference name="android-minSdkVersion" value="7" />
    <preference name="android-installLocation" value="auto" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="10000" />
    <icon src="icon.png" />
    <icon gap:density="ldpi" gap:platform="android" src="res/icon/android/icon-36-ldpi.png" />
    <icon gap:density="mdpi" gap:platform="android" src="res/icon/android/icon-48-mdpi.png" />
    <icon gap:density="hdpi" gap:platform="android" src="res/icon/android/icon-72-hdpi.png" />
    <icon gap:density="xhdpi" gap:platform="android" src="res/icon/android/icon-96-xhdpi.png" />
    <icon gap:platform="blackberry" src="res/icon/blackberry/icon-80.png" />
    <icon gap:platform="blackberry" gap:state="hover" src="res/icon/blackberry/icon-80.png" />
    <icon gap:platform="ios" height="57" src="res/icon/ios/icon-57.png" width="57" />
    <icon gap:platform="ios" height="72" src="res/icon/ios/icon-72.png" width="72" />
    <icon gap:platform="ios" height="114" src="res/icon/ios/icon-57-2x.png" width="114" />
    <icon gap:platform="ios" height="144" src="res/icon/ios/icon-72-2x.png" width="144" />
    <icon gap:platform="webos" src="res/icon/webos/icon-64.png" />
    <icon gap:platform="winphone" src="res/icon/windows-phone/icon-48.png" />
    <icon gap:platform="winphone" gap:role="background" src="res/icon/windows-phone/icon-173.png" />
    <gap:splash gap:density="ldpi" gap:platform="android" src="res/screen/android/screen-ldpi-portrait.png" />
    <gap:splash gap:density="mdpi" gap:platform="android" src="res/screen/android/screen-mdpi-portrait.png" />
    <gap:splash gap:density="hdpi" gap:platform="android" src="res/screen/android/screen-hdpi-portrait.png" />
    <gap:splash gap:density="xhdpi" gap:platform="android" src="res/screen/android/screen-xhdpi-portrait.png" />
    <gap:splash gap:platform="blackberry" src="res/screen/blackberry/screen-225.png" />
    <gap:splash gap:platform="ios" height="480" src="res/screen/ios/screen-iphone-portrait.png" width="320" />
    <gap:splash gap:platform="ios" height="960" src="res/screen/ios/screen-iphone-portrait-2x.png" width="640" />
    <gap:splash gap:platform="ios" height="1024" src="res/screen/ios/screen-ipad-portrait.png" width="768" />
    <gap:splash gap:platform="ios" height="768" src="res/screen/ios/screen-ipad-landscape.png" width="1024" />
    <gap:splash gap:platform="winphone" src="res/screen/windows-phone/screen-portrait.jpg" />
    <access origin="http://127.0.0.1*" />
</widget>

由于闪屏没有显示,我还应该添加什么?

【问题讨论】:

  • 您是否将初始屏幕图像放置在正确的文件夹中?您正在为哪些平台构建?
  • @Dawson Loudon 我为 android 构建它,并且在 www/res/screen 和 android\assets\www\res\screen 中没有显示默认的 .png 图像......而且还有android\res\drawable-xhdpi 中还有一些默认图像...不知道为什么,或者它们是否需要在那里,因为它们已经在 res 文件夹中..
  • 您需要将图像(具体命名为 screen.png)添加到 android\res\drawable 和所有 \drawable- 目录。 www\res\screen 仅在您使用 build.phonegap.com 服务时使用,他们的文档对此不是很清楚。
  • @Dawson Loudon 但我在这篇帖子stackoverflow.com/questions/21831395/… 中被告知闪屏也适用于 CLI 构建...!?
  • @DawsonLoudon Loudon 无论如何,我将文件添加到可绘制文件夹中,但什么也没发生。这适用于 onlinebuild、cli build 还是 eclipse build?

标签: cordova phonegap-plugins splash-screen cordova-3


【解决方案1】:

假设您正在为 Android 构建是否安全?如果是这样,请按照 PhoneGap 文档页面上的说明进行操作:http://docs.phonegap.com/en/3.4.0/config_ref_images.md.html#Icons%20and%20Splash%20Screens

确保你在 config.xml 中有这些:

<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="10000" />

然后将初始屏幕图像的副本(每个都具有目标平台的正确分辨率)放入 drawable* 文件夹中,如下所示:

platforms/android/res/drawable/screen.png
platforms/android/res/drawable-hdpi/screen.png
platforms/android/res/drawable-ldpi/screen.png
platforms/android/res/drawable-mdpi/screen.png
platforms/android/res/drawable-xhdpi/screen.png

另外,建议从您的配置文件中删除它:

&lt;preference name="auto-hide-splash-screen" value="true" /&gt;

【讨论】:

  • 一切都编译得很好,但是当我打开应用程序时它崩溃了,没有任何消息。
【解决方案2】:

您需要执行以下步骤:

 Add these to res/config.xml
 <preference name="SplashScreen" value="screen" />
 <preference name="SplashScreenDelay" value="10000" />

然后将您的屏幕以 png 格式添加到以下文件夹中

"Your Project Directory"\platforms\android\bin\res\crunch\drawable-land-hdpi
"Your Project Directory"\platforms\android\bin\res\crunch\drawable-land-ldpi
"Your Project Directory"\platforms\android\bin\res\crunch\drawable-land-mdpi
"Your Project Directory"\platforms\android\bin\res\crunch\drawable-land-xhdpi
"Your Project Directory"\platforms\android\bin\res\crunch\drawable-port-hdpi
"Your Project Directory"\platforms\android\bin\res\crunch\drawable-port-ldpi
"Your Project Directory"\platforms\android\bin\res\crunch\drawable-port-mdpi
"Your Project Directory"\platforms\android\bin\res\crunch\drawable-port-xhdpi

也在这些文件夹中

 "Your Project Directory"\platforms\android\res\crunch\drawable-land-hdpi
"Your Project Directory"\platforms\android\res\crunch\drawable-land-ldpi
"Your Project Directory"\platforms\android\res\crunch\drawable-land-mdpi
"Your Project Directory"\platforms\android\res\crunch\drawable-land-xhdpi
"Your Project Directory"\platforms\android\res\crunch\drawable-port-hdpi
"Your Project Directory"\platforms\android\res\crunch\drawable-port-ldpi
"Your Project Directory"\platforms\android\res\crunch\drawable-port-mdpi
"Your Project Directory"\platforms\android\res\crunch\drawable-port-xhdpi

刷新您的项目,然后“运行”。您已完成。

确保您的屏幕名称为“screen.png”,否则您可能会在 androidmanifest.xml 中出现错误,您必须更改 androidmanifest.xml 最好的方法是您的屏幕必须命名为“screen.png” .

【讨论】:

    猜你喜欢
    • 2018-12-07
    • 1970-01-01
    • 2014-10-12
    • 2014-05-05
    • 2016-04-19
    • 1970-01-01
    • 2014-09-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多