当为PhoneGap应用程序设置闪屏时,即使我制作了一个带有标志的大图片,图片也会被拉伸到整个屏幕上。理想情况下,我希望图片只在中心位置,背景为黑色或白色。如何配置闪屏的行为?
当为PhoneGap应用程序设置闪屏时,即使我制作了一个带有标志的大图片,图片也会被拉伸到整个屏幕上。理想情况下,我希望图片只在中心位置,背景为黑色或白色。如何配置闪屏的行为?
有一个更好的解决方案可用:将以下splash.xml放置在res / drawable中(修改android:src属性),并更改对R.drawable.splash的引用,以在setIntegerProperty()调用中使用。
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/splashImage"
android:gravity="center_horizontal|center_vertical" />
请查看我的博客,以获得更详细的设置说明。
int ot = getResources().getConfiguration().orientation;
if (ot == 2) {
super.setIntegerProperty("splashscreen", R.drawable.splashlandscape);
Log.d("Orientation", "Landscape");
}
else {
super.setIntegerProperty("splashscreen", R.drawable.splashportrait);
Log.d("Orientation", "Portrait");
}
这是一个解决方案,但它有缺陷。
将您的splash.png放入各种drawable文件夹中。
res/drawable/splash.png (480wx800h portrait version)
res/drawable-land/splash.png (800wx480h landscape version)
这种方法的已知问题是,如果在加载后更改方向,则不会更新背景...(这对于PhoneGap 1.10是正确的)
/drawable-port-xhdpi/splash.png
、/drawable-port-mdpi/splash.png
、/drawable-port-ldpi/splash.png
和/drawable-port-hdpi/splash.png
中的PNG文件。我尝试通过将新的splash.xml
放置在drawable目录中来引用它,但是那样不起作用。所以,我不得不创建一个splash.xml
文件来替换每个splash.png
文件,然后在每个目录中将splash.png
重命名为splashimage.png
(请注意小写字母的注释)。希望这能帮助大家。 - Ian Jamieson