use*_*646 13 screen splash-screen stretch nine-patch cordova
当我的phonegap应用程序启动时,我会弹出一个假的闪屏:
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 500);
Run Code Online (Sandbox Code Playgroud)
我目前有3个不同的splash.png文件:hdpi,mdpdi和ldpi.我的问题是即使在hdpi中,你也会得到480 x 800的设备和480 x 854的其他设备,并且android会拉伸我的启动图像来填充屏幕.
我宁愿让图像保持其纵横比.据我所知,9补丁解决方案不适用于PhoneGap.如果愿意,请告诉我如何!我准备好了.9.png了.所以我能想到的其他解决方案是防止android扩展我的图像.我该怎么办?
谢谢!
rob*_*ert 14
9补丁解决方案适用于PhoneGap中的闪屏:-)
通过创建一个xml文件来定义一个新的可绘制资源,即res/drawable/splash.xml,其中包含以下内容:
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/splashimg"
android:dither="false"/>;
Run Code Online (Sandbox Code Playgroud)
请注意它如何引用真实图像'splashimg',它应该是九个补丁图像(见下文).
创建九个补丁图像
在res/drawable或特定于分辨率的文件夹中添加引用的九个补丁图像,例如res/drawable/splashimg.9.png
在DroidGap扩展类中引用新的drawable
public void onCreate(Bundle savedInstanceState) {
super.setIntegerProperty("splashscreen", R.drawable.splash);
}
Run Code Online (Sandbox Code Playgroud)通过使用android中可绘制资源的强大功能,您可以实际制作各种背景图像/效果.有关详细信息,请参阅http://developer.android.com/guide/topics/resources/drawable-resource.html.
Flo*_*ian 12
无需提出错误,有一个可用的解决方案:只需将以下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" />
Run Code Online (Sandbox Code Playgroud)
请参阅我的博客以获取有关设置的更详细说明.
| 归档时间: |
|
| 查看次数: |
13237 次 |
| 最近记录: |