android.view.InflateException:二进制XML文件行(不存在)

时间:2018-11-11 11:12:47

标签: android layout android-constraintlayout layout-inflater

我有这样的布局:

localhost:8000/home/myads/{id}/delete

我得到一个非常普遍的通胀错误:

<?xml version="1.0" encoding="utf-8"?>
<merge>
  <android.support.constraint.ConstraintLayout
      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:id="@+id/has_selected_account"
      android:layout_width="match_parent"
      android:layout_height="wrap_content">

    <TextView
        android:id="@+id/account_display_name"
        android:layout_width="wrap_content"
        android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
        android:layout_marginBottom="@dimen/account_menu_name_and_display_vertical_padding"
        app:layout_constraintBottom_toTopOf="@+id/account_name"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_chainStyle="packed"
        tools:text="DisplayNameIsLongSoItShouldBeTruncatedAtSomePoint"/>
    <TextView
        android:id="@+id/account_name"
        android:layout_width="wrap_content"
        android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
        android:layout_marginBottom="@dimen/account_menu_name_and_display_vertical_padding"
        android:includeFontPadding="false"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/account_display_name"
        tools:text="emailisverylongaswellwewantittogettruncated@gmail.longdomain.com"/>
  </android.support.constraint.ConstraintLayout>
</merge>

(这样剪切)

我试图简化我的XML。我该如何解决通胀错误?

另外,我的布局XML不像#39 所以这指的是什么?

2 个答案:

答案 0 :(得分:2)

您同时缺少android:layout_height的{​​{1}},这就是查看通胀错误的方法。当视图膨胀时,它可能需要通过其他类或方法来解析TextView标记,这似乎具有不同的错误解析方式。否则,您会看到一个更清晰的错误,缺少merge

答案 1 :(得分:0)

请使用这个。

<?xml version="1.0" encoding="utf-8"?>
<merge>
  <android.support.constraint.ConstraintLayout
      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:id="@+id/has_selected_account"
      android:layout_width="match_parent"
      android:layout_height="wrap_content">

    <TextView
        android:id="@+id/account_display_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
        android:layout_marginBottom="@dimen/account_menu_name_and_display_vertical_padding"
        app:layout_constraintBottom_toTopOf="@+id/account_name"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_chainStyle="packed"
        tools:text="DisplayNameIsLongSoItShouldBeTruncatedAtSomePoint"/>
    <TextView
        android:id="@+id/account_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/account_menu_name_and_display_vertical_padding"
        android:layout_marginBottom="@dimen/account_menu_name_and_display_vertical_padding"
        android:includeFontPadding="false"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/account_display_name"
        tools:text="emailisverylongaswellwewantittogettruncated@gmail.longdomain.com"/>
  </android.support.constraint.ConstraintLayout>
</merge>