当设置phonegap应用程序的闪屏时,图片会在整个屏幕上拉伸,即使我制作了一个中心带有徽标的大图片。理想情况下,我希望图片只坐在黑色或白色背景的中心。如何配置闪屏的行为?
发布于 2012-03-01 17:56:06
有一个更好的解决方案:只需将以下splash.xml放在res/drawable中(修改android:src属性),并在setIntegerProperty()调用中将引用更改为R.drawable.splash。
<?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" />
有关设置的更详细说明,请参阅我的Blog。
发布于 2011-11-16 05:03:24
我只是根据启动时的当前方向来设置闪屏。不是很完美,但很管用。你可以走得更远,在方向上的广告改变同样的效果,但有人在闪屏启动期间改变方向的机会很小。
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");
}
发布于 2011-10-12 22:44:32
这是一种解决方案,但它也有缺陷
把你的splash.png放在各种可抽屉的文件夹中
res/drawable/splash.png (480wx800h portrait version)
res/drawable-land/splash.png (800wx480h landscape version)
这个方法的已知问题是,如果加载后方向发生变化,它不会更新背景...(这适用于phonegap 1.10)
https://stackoverflow.com/questions/7380121
复制相似问题