How to add separate Portrait and Landscape splash Images to Android config.xml gap:splash

我只是一个虾纸丫 提交于 2019-12-07 16:14:07

问题


The question here is how to allow for separate (landscape and portrait) splash images in PhoneGap.


回答1:


Unable to find a satisfactory answer for a long time, I finally spent a few hours messing with it and was able to get it to work in the following way: define two items for each android size- on the portrait files, DON'T put width and height attributes, and on the landscape DO put them.

Here is my code so others can follow:

EDIT: THE CODE BELOW IS FOR PHONE GAP BUILD VERSIONS 2.7 THROUGH 3.0. FOR NEWER VERSIONS, SEE https://stackoverflow.com/a/24002601/700111 AND http://docs.phonegap.com/en/3.5.0/config_ref_images.md.html#Icons%20and%20Splash%20Screens.

THIS DID NOT WORK - when i had width and height on the portrait files:

<gap:splash src="res/screen/android/screen-xhdpi-n7-landscape.png" gap:platform="android" gap:density="xhdpi" width="1280" height="800" />
<gap:splash src="res/screen/android/screen-xhdpi-landscape.png" gap:platform="android" gap:density="xhdpi" width="1280" height="720" />
<gap:splash src="res/screen/android/screen-hdpi-landscape.png"  gap:platform="android" gap:density="hdpi" width="800" height="480" />
<gap:splash src="res/screen/android/screen-mdpi-landscape.png"  gap:platform="android" gap:density="mdpi" width="480" height="320" />
<gap:splash src="res/screen/android/screen-ldpi-landscape.png"  gap:platform="android" gap:density="ldpi" width="320" height="200" />

And this is the WORKING CODE

 <gap:splash src="res/screen/android/screen-xhdpi-portrait.png" gap:platform="android" gap:density="xhdpi"/>
<gap:splash src="res/screen/android/screen-xhdpi-n7-portrait.png" gap:platform="android" gap:density="xhdpi"/>
<gap:splash src="res/screen/android/screen-hdpi-portrait.png"  gap:platform="android" gap:density="hdpi"/>
<gap:splash src="res/screen/android/screen-mdpi-portrait.png"  gap:platform="android" gap:density="mdpi"/>
<gap:splash src="res/screen/android/screen-ldpi-portrait.png"  gap:platform="android" gap:density="ldpi"/>

<gap:splash src="res/screen/android/screen-xhdpi-n7-landscape.png" gap:platform="android" gap:density="xhdpi" width="1280" height="800" />
<gap:splash src="res/screen/android/screen-xhdpi-landscape.png" gap:platform="android" gap:density="xhdpi" width="1280" height="720" />
<gap:splash src="res/screen/android/screen-hdpi-landscape.png"  gap:platform="android" gap:density="hdpi" width="800" height="480" />
<gap:splash src="res/screen/android/screen-mdpi-landscape.png"  gap:platform="android" gap:density="mdpi" width="480" height="320" />
<gap:splash src="res/screen/android/screen-ldpi-landscape.png"  gap:platform="android" gap:density="ldpi" width="320" height="200" />

I was able to have different landscape and portrait files using this code.

Hope this helps someone!

--techdude




回答2:


I am using Phonegap 3.4.0, I had to add "gap:qualifier" to make it work:

<gap:splash gap:density="ldpi" gap:platform="android" src="res/screen/android/screen-ldpi-landscape.png" gap:qualifier="land-ldpi" />
<gap:splash gap:density="mdpi" gap:platform="android" src="res/screen/android/screen-mdpi-landscape.png" gap:qualifier="land-mdpi" />
<gap:splash gap:density="hdpi" gap:platform="android" src="res/screen/android/screen-hdpi-landscape" gap:qualifier="land-hdpi" />
<gap:splash gap:density="xhdpi" gap:platform="android" src="res/screen/android/screen-xhdpi-landscape.png" gap:qualifier="land-xhdpi" />


来源:https://stackoverflow.com/questions/16951297/how-to-add-separate-portrait-and-landscape-splash-images-to-android-config-xml-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!