将布局与背景图像和图像按钮放在一起时的运行时错误?

时间:2014-03-29 00:19:21

标签: android android-layout

我使用android-8(2.2),当我尝试将背景设置为linearlayout并放置一个图像按钮时,它会产生运行时错误。有谁知道如何在这个Android版本中修复它?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:id="@+id/signUpLayout"
              android:background="@drawable/loginbackground">
    <ImageButton android:layout_width="fill_parent"
                         android:layout_height="fill_parent"
                         android:id="@+id/signUpButton"
                         android:src="@drawable/facebooksignupbutton"
                         android:scaleType="centerCrop"
                         android:background="@android:color/transparent"
                         android:clickable="true"/>

</LinearLayout>

以下是日志:

03-29 03:06:46.820: ERROR/AndroidRuntime(1012): FATAL EXCEPTION: main
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.CashFinance/com.CashFinance.SignUpPage}: android.view.InflateException: Binary XML file line #24: Error inflating class android.widget.ImageButton
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2362)
        at android.app.ActivityThread.access$700(ActivityThread.java:168)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1329)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5493)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: android.view.InflateException: Binary XML file line #24: Error inflating class android.widget.ImageButton
        at android.view.LayoutInflater.createView(LayoutInflater.java:626)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
        at android.app.Activity.setContentView(Activity.java:1956)
        at com.CashFinance.SignUpPage.onCreate(SignUpPage.java:20)
        at android.app.Activity.performCreate(Activity.java:5372)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
        ... 11 more
        Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.constructNative(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
        at android.view.LayoutInflater.createView(LayoutInflater.java:600)
        ... 26 more
        Caused by: java.lang.OutOfMemoryError
        at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
        at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
        at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
        at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832)
        at android.content.res.Resources.loadDrawable(Resources.java:2988)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
        at android.widget.ImageView.<init>(ImageView.java:131)
        at android.widget.ImageButton.<init>(ImageButton.java:88)
        at android.widget.ImageButton.<init>(ImageButton.java:84)
        ... 29 more

0 个答案:

没有答案