无法运行xml代码

时间:2017-04-26 23:57:26

标签: android xml

我想问为什么每次执行我的代码我的模拟器总是显示“不幸的是,程序已停止”

我的代码有什么问题? 即时通讯使用API​​21和我的模拟器我使用lolipop 5.0

xml代码

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background"
>

<LinearLayout
    android:id="@+id/LinearLayout1"
    android:layout_width="280dp"
    android:layout_height="50dp"
    android:orientation="vertical"
    >
</LinearLayout>

<RelativeLayout
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >

    <LinearLayout
        android:id="@+id/LinearLayout2"
        android:layout_width="280dp"
        android:layout_height="65dp"
        android:orientation="vertical"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true">

        <ImageView
            android:id="@+id/Logo"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/logo4"
            />

    </LinearLayout>

</RelativeLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="30dp"
    android:orientation="vertical"
    ></LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:orientation="vertical"
    >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button
            android:id="@+id/Icon1"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:layout_marginTop="18dp"
            android:layout_marginLeft="25dp"
            android:background="@drawable/icon1"
            />

        <Button
            android:id="@+id/Icon2"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:layout_marginTop="18dp"
            android:layout_marginRight="25dp"
            android:background="@drawable/icon2"
            />

    </RelativeLayout>
</LinearLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true">
        <Button
            android:id="@+id/Icon3"
            android:layout_width="100dp"
            android:layout_height="100dp"
            android:background="@drawable/icon3"
            android:layout_marginTop="18dp"
            />
    </LinearLayout>

</RelativeLayout>

all image i put in drawable folder

logcat的

04-26 19:36:13.697 1957-1957/dproject.user.applicationtest E/AndroidRuntime: FATAL EXCEPTION: main
                                                                         Process: dproject.user.applicationtest, PID: 1957
                                                                         java.lang.OutOfMemoryError: Failed to allocate a 16000012 byte allocation with 5290208 free bytes and 5MB until OOM
                                                                             at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
                                                                             at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
                                                                             at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
                                                                             at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
                                                                             at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:973)
                                                                             at android.content.res.Resources.loadDrawableForCookie(Resources.java:2423)
                                                                             at android.content.res.Resources.loadDrawable(Resources.java:2330)
                                                                             at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
                                                                             at android.view.View.<init>(View.java:3730)
                                                                             at android.widget.TextView.<init>(TextView.java:634)
                                                                             at android.widget.Button.<init>(Button.java:111)
                                                                             at android.widget.Button.<init>(Button.java:107)
                                                                             at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:66)
                                                                             at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:62)
                                                                             at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:109)
                                                                             at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1021)
                                                                             at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1080)
                                                                             at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:47)
                                                                             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:725)
                                                                             at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
                                                                             at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
                                                                             at android.view.LayoutInflater.rInflate(LayoutInflater.java:809)
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
                                                                             at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288)
                                                                             at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                             at dproject.user.applicationtest.MainActivity.onCreate(MainActivity.java:11)
                                                                             at android.app.Activity.performCreate(Activity.java:5933)
                                                                             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
                                                                             at android.app.ActivityThread.access$800(ActivityThread.java:144)
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                             at android.os.Looper.loop(Looper.java:135)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5221)
                                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                                             at java.lang.reflect.Method.invoke(Method.java:372)
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

0 个答案:

没有答案