我在XML(splashscreen.xml)中有以下布局:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frmLayout" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:id="@+id/splash"
android:src="@drawable/splash"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:scaleType="fitXY" />
</FrameLayout>
SplashScreen.java:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
// more code...
}
当我尝试在Android 1.5中执行它(在所有其他版本中正确执行)时,我收到以下错误:
08-16 19:24:04.569: ERROR/AndroidRuntime(1002): Uncaught handler: thread main exiting due to uncaught exception
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.project/com.project.SplashScreen}: android.view.InflateException: Binary XML file line #5: Error inflating class java.lang.reflect.Constructor
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.app.ActivityThread.access$1800(ActivityThread.java:112)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.os.Handler.dispatchMessage(Handler.java:99)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.os.Looper.loop(Looper.java:123)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.app.ActivityThread.main(ActivityThread.java:3948)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at java.lang.reflect.Method.invokeNative(Native Method)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at java.lang.reflect.Method.invoke(Method.java:521)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at dalvik.system.NativeStart.main(Native Method)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): Caused by: android.view.InflateException: Binary XML file line #5: Error inflating class java.lang.reflect.Constructor
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.view.LayoutInflater.createView(LayoutInflater.java:512)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.view.LayoutInflater.rInflate(LayoutInflater.java:617)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:309)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.app.Activity.setContentView(Activity.java:1626)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at com.project.SplashScreen.onCreate(SplashScreen.java:34)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): ... 11 more
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): Caused by: java.lang.reflect.InvocationTargetException
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.widget.ImageView.<init>(ImageView.java:103)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at java.lang.reflect.Constructor.constructNative(Native Method)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.view.LayoutInflater.createView(LayoutInflater.java:499)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): ... 22 more
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/title_bar_shadow.9.png from drawable resource ID #0x7f020021
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.content.res.Resources.loadDrawable(Resources.java:1641)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.widget.ImageView.<init>(ImageView.java:113)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): ... 26 more
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): Caused by: java.io.FileNotFoundException: res/drawable/title_bar_shadow.9.png
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.content.res.AssetManager.openNonAssetNative(Native Method)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.content.res.AssetManager.openNonAsset(AssetManager.java:392)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): at android.content.res.Resources.loadDrawable(Resources.java:1634)
08-16 19:24:04.619: ERROR/AndroidRuntime(1002): ... 28 more
08-16 19:25:39.511: ERROR/AndroidRuntime(1045): Uncaught handler: thread main exiting due to uncaught exception
第5行对应 ImageView 行。你知道为什么我的程序在1.5以外的所有Android版本中执行吗?
谢谢!