Android的启动画面:如何使它为中心? [英] Android splash screen: how to make it centered?
问题描述
我使用基于主题的解决方案,因为它这里描述,例如,
展现在我的应用程序启动画面。结果
这里是我的background_launch.xml:
I use a theme-based solution as it described here, for example,
to show a splash screen in my application.
Here is my background_launch.xml:
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/launch_image"
android:tileMode="disabled" />
当我有 launch_image
以PNG一切正常。但应用程序崩溃,如果我用 @绘制/ layerlist
而不是 @绘制/ launch_image
。结果
layerlist.xml是:
When I have launch_image
as png everything is OK. But the app crashes if I use @drawable/layerlist
instead of @drawable/launch_image
.
layerlist.xml is:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap
android:gravity="center"
android:src="@drawable/launch_image"
android:tileMode="disabled" >
</bitmap>
</item>
</layer-list>
该应用程序崩溃与以下日志(几行被跳过):
The app crashed with the following log (several lines are skipped):
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.glu.pathlight/com.glu.pathlight.JSFinalNativeActivity}: android.content.res.Resources$NotFoundException: File res/drawable/background_launch.xml from drawable resource ID #0x7f020000
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
...
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/background_launch.xml from drawable resource ID #0x7f020000
at android.content.res.Resources.loadDrawable(Resources.java:2096)
at android.content.res.Resources.getDrawable(Resources.java:700)
... 11 more
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #18: <bitmap> requires a valid src attribute
at android.graphics.drawable.BitmapDrawable.inflate(BitmapDrawable.java:571)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:937)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:877)
at android.content.res.Resources.loadDrawable(Resources.java:2092)
... 22 more
什么是错误的,我的资源?
What is wrong in my resources?
推荐答案
将这个:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap
android:gravity="center"
android:src="@drawable/launch_image"
android:tileMode="disabled" >
</bitmap>
</item>
</layer-list>
在 background_launch.xml
,而不是试图引用的状态列表的android:SRC
为&LT;位图\\&GT;
一个状态列表不是一个位图 - 这就是错误的告诉你
A state list is not a bitmap -- that's what the error's telling you.
这篇关于Android的启动画面:如何使它为中心?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!