当我的 phonegap 应用程序启动时,我有一个假的闪屏:
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 500);
我目前有 3 个不同的 splash.png 文件:hdpi、mdpdi 和 ldpi。我的问题是,即使在 hdpi 中,您也会获得 480 x 800 和其他 480 x 854 的设备,并且 android 会拉伸(stretch)我的启动图像以填满屏幕。
我宁愿让图像保持其纵横比。根据我的阅读,9 补丁解决方案不适用于 PhoneGap。如果会,请告诉我如何!我已经准备好 .9.png 了。
所以我能想到的另一个解决方案是防止android拉伸(stretch)我的图像。我该怎么做?
谢谢!
最佳答案
9 补丁解决方案确实适用于 PhoneGap 中的闪屏 :-)
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/splashimg"
android:dither="false"/>;
请注意它是如何引用真实图像“splashimg”的,该图像应该是 9-patch 图像(见下文)。
(见 http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch )
例如res/drawable/splashimg.9.png
public void onCreate(Bundle savedInstanceState) {
super.setIntegerProperty("splashscreen", R.drawable.splash);
}
通过这种方式,您实际上可以通过使用 android 中可绘制资源的强大功能来制作各种背景图像/效果。见 http://developer.android.com/guide/topics/resources/drawable-resource.html更多。
关于cordova - Android的Phonegap启动画面: not stretched or 9patch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9204573/