2014-02-18 36 views
8

如何正確顯示splashscreen?我使用CLi本地構建,我聽說它是​​兼容的。 我添加插件:PhoneGap的插件添加org.apache.cordova.splashscreen 這是我的配置文件:如何在Phonegap中顯示畫面3.3

<?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="[email protected]" 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> 

我還需要補充,因爲濺射屏幕不顯示?

+0

你把你的啓動畫面圖像放在正確的文件夾?你在爲哪個平臺建設? –

+0

@Dawson Loudon我建立它的android和有缺省的.png圖像在www/res /屏幕和android \ assets \ www \ res \屏幕極其不顯示...並且還有一些默認圖像在android \ res \ drawable-xhdpi ...不知道爲什麼,或者如果他們需要在那裏,因爲他們已經在res文件夾中.. –

+2

你會想要添加你的圖像(具體命名爲screen.png)android \ res \ drawable和所有* \ drawable- *目錄。 www \ res \ screen只有在你使用build.phonegap.com服務的時候,他們的文檔不是很清楚。 –

回答

5

假設您正在爲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" /> 

然後把你的閃屏圖像的副本(每個具有用於正確的分辨率目標平臺)中繪製*文件夾,如:

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 

此外,建議從您的配置文件中刪除此:

<preference name="auto-hide-splash-screen" value="true" />

+0

一切編譯好,但一打開應用程序它崩潰沒有任何消息。 – Sebastialonso

0

你需要以下步驟:

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也是最好的辦法是,你的屏幕必須B產品名稱爲「屏幕巴紐」。