具有多个屏幕的Android Inflate例外

时间:2015-09-29 07:15:11

标签: android android-layout

我正在创建一个支持多种屏幕尺寸的应用。因此我创建了3个布局文件夹,即布局,布局小和布局大。 但是当我在不同的手机上运行这个应用程序时,它会在不同的屏幕上崩溃并显示二进制膨胀异常。 此外,在android studio的预览窗口中,它没有从普通文件夹中选择布局。它显示了布局和布局小的布局。 请指出我的错误,并提前感谢。 为其中一个屏幕添加layout-large

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/blue_bg"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <ImageView
        android:layout_width="200dp"
        android:layout_height="150dp"
        android:src="@drawable/logo"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="10dp"
        android:id="@+id/iv_logo"/>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        >
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="be connected."
            android:textColor="#ffffff"
            android:layout_marginLeft="30dp"
            android:id="@+id/tv_connect"
            android:textSize="54sp"
            android:textStyle="bold"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="be one."
            android:textSize="54sp"
            android:textStyle="bold"
            android:layout_marginLeft="5dp"
            android:textColor="#303359"/>
    </LinearLayout>
    <VideoView
        android:layout_width="match_parent"
        android:layout_height="350dp"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="50dp"
        android:layout_marginRight="30dp"
        android:id="@+id/video"/>
</LinearLayout>

这是错误日志

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.webninjaz.one/com.webninjaz.one.MainActivity}: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class <unknown>
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
     Caused by: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class <unknown>
            at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
            at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:255)
            at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:109)
            at com.webninjaz.one.MainActivity.onCreate(MainActivity.java:13)
            at android.app.Activity.performCreate(Activity.java:6237)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
            at android.app.ActivityThread.-wrap11(ActivityThread.java)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:148)
            at android.app.ActivityThread.main(ActivityThread.java:5417)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

0 个答案:

没有答案