首页 > 解决方案 > android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class Button

问题描述

我的代码中出现此错误。请帮我解决这个问题。

android.view.InflateException:二进制 XML 文件第 16 行:二进制 XML 文件第 16 行:在 android.view.LayoutInflater.inflate(LayoutInflater.java:543) 在 android.view.LayoutInflater.inflate(LayoutInflater. java:427) 在 com.kensai.kensaicashier.adapter.EditMenuAdapter.onCreateViewHolder(EditMenuAdapter.kt:14) 在 android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6685)

这是我的 xml 文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <RelativeLayout
        android:id="@+id/lay4"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:background="@color/colorGray">

        <TextView
            android:id="@+id/waktu_pesan_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/waktu_pesan"
            android:textColor="@color/colorBlack"
            android:textSize="16sp"
            android:layout_centerVertical="true"
            android:layout_marginStart="40dp" />

        <TextView
            android:id="@+id/waktu_pesan"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="13:44"
            android:textColor="@color/colorBlack"
            android:textSize="16sp"
            android:layout_marginStart="140dp"
            android:background="@color/colorGray"
            android:layout_centerVertical="true"/>

    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/lay5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginStart="40dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/total_pesanan_title"
            android:textColor="@color/colorBlack"
            android:layout_centerVertical="true"/>

        <TextView
            android:id="@+id/total_pesanan"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="8 item"
            android:textColor="@color/colorBlack"
            android:layout_marginStart="100dp"
            android:layout_centerVertical="true"/>

        <Button
            android:id="@+id/btn_tambah_menu"
            android:layout_width="150dp"
            android:layout_height="30dp"
            android:text="@string/tambah_menu"
            android:textSize="16sp"
            android:textColor="@color/colorWhite"
            android:background="@drawable/round_button_solid"
            android:layout_alignParentEnd="true"
            android:layout_marginEnd="40dp"
            android:layout_marginBottom="10dp"
            android:layout_centerVertical="true"
            android:textAllCaps="false"/>

    </RelativeLayout>

    <ScrollView
        android:id="@+id/scrollView_take_away"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/lay5"
        android:layout_below="@id/lay4">

        <android.support.v7.widget.CardView
            android:id="@+id/card_order_take_away"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="40dp"
            android:layout_marginEnd="40dp"
            android:layout_marginTop="10dp"
            app:contentPadding="10dp"
            app:cardElevation="5dp">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/rec_edit_menu"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:clipToPadding="false" />

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/rec_order_take_away"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/rec_edit_menu"/>

            </RelativeLayout>

        </android.support.v7.widget.CardView>

    </ScrollView>

</RelativeLayout>

标签: javaandroidxmlandroid-layoutkotlin

解决方案


推荐阅读