我正在尝试将我用三星S4设备制作的4.41 KB启动图像放到我的应用程序中,但是当我将其存储在此目录drawable-hdpi中时,我收到了下面的错误。我甚至尝试将其存储在ldpi、mdpi、xhdpi和xxhdpi中,在这种情况下,我会得到一个没有图像的白色启动背景。
我从互联网上下载了一张800x600像素大小和494 KB的图片。我将它放在drawable-hdpi目录中,它工作正常(该图片被显示为启动屏幕),但是我想将自己的S4设备图像作为背景。我该如何解决呢?
XML文件:
我从互联网上下载了一张800x600像素大小和494 KB的图片。我将它放在drawable-hdpi目录中,它工作正常(该图片被显示为启动屏幕),但是我想将自己的S4设备图像作为背景。我该如何解决呢?
XML文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background= "@drawable/splash_background"
>
</LinearLayout>
错误:
08-02 12:24:01.781: E/AndroidRuntime(15857): FATAL EXCEPTION: main
08-02 12:24:01.781: E/AndroidRuntime(15857): Process: com.bustracker, PID: 15857
08-02 12:24:01.781: E/AndroidRuntime(15857): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bustracker/com.bustracker.Splash}: android.view.InflateException: Binary XML file line #3: Error inflating class <unknown>
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2760)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.app.ActivityThread.access$900(ActivityThread.java:177)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.os.Handler.dispatchMessage(Handler.java:102)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.os.Looper.loop(Looper.java:145)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.app.ActivityThread.main(ActivityThread.java:5944)
08-02 12:24:01.781: E/AndroidRuntime(15857): at java.lang.reflect.Method.invoke(Native Method)
08-02 12:24:01.781: E/AndroidRuntime(15857): at java.lang.reflect.Method.invoke(Method.java:372)
08-02 12:24:01.781: E/AndroidRuntime(15857): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1389)
08-02 12:24:01.781: E/AndroidRuntime(15857): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)
08-02 12:24:01.781: E/AndroidRuntime(15857): Caused by: android.view.InflateException: Binary XML file line #3: Error inflating class <unknown>
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.view.LayoutInflater.createView(LayoutInflater.java:640)
08-02 12:24:01.781: E/AndroidRuntime(15857): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
08-02 12:24:01.781: E/AndroidRuntime(15857): at com.bustracker.Splash.onCreate(Splash.java:13)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.app.Activity.performCreate(Activity.java:6289)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
08-02 12:24:01.781: E/AndroidRuntime(15857): ... 10 more
08-02 12:24:01.781: E/AndroidRuntime(15857): Caused by: java.lang.reflect.InvocationTargetException
08-02 12:24:01.781: E/AndroidRuntime(15857): at java.lang.reflect.Constructor.newInstance(Native Method)
08-02 12:24:01.781: E/AndroidRuntime(15857): at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.view.LayoutInflater.createView(LayoutInflater.java:614)
08-02 12:24:01.781: E/AndroidRuntime(15857): ... 22 more
08-02 12:24:01.781: E/AndroidRuntime(15857): Caused by: java.lang.OutOfMemoryError: Failed to allocate a 153363468 byte allocation with 8388608 free bytes and 112MB until OOM
08-02 12:24:01.781: E/AndroidRuntime(15857): at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:726)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:547)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1014)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.content.res.Resources.loadDrawableForCookie(Resources.java:3730)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.content.res.Resources.loadDrawable(Resources.java:3603)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.content.res.TypedArray.getDrawable(TypedArray.java:762)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.view.View.<init>(View.java:3970)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.view.ViewGroup.<init>(ViewGroup.java:507)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.widget.LinearLayout.<init>(LinearLayout.java:199)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.widget.LinearLayout.<init>(LinearLayout.java:195)
08-02 12:24:01.781: E/AndroidRuntime(15857): at android.widget.LinearLayout.<init>(LinearLayout.java:191)
08-02 12:24:01.781: E/AndroidRuntime(15857): ... 25 more