【问题标题】:Binary XML file line : Error inflating class android.support.v7.widget.CardView二进制 XML 文件行:膨胀类 android.support.v7.widget.CardView 时出错
【发布时间】:2019-04-25 19:27:20
【问题描述】:
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.netvariant.nissan_survey.MainActivity" >
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin" >
    <ImageView
        android:layout_width="244dp"
        android:layout_height="70dp"
        android:layout_alignParentLeft="true"
        android:contentDescription="@string/app_name"
        android:src="@drawable/header_feedback" >
    </ImageView>
    <ImageView
        android:layout_width="244dp"
        android:layout_height="70dp"
        android:layout_alignParentRight="true"
        android:contentDescription="@string/app_name"
        android:src="@drawable/logo" >
    </ImageView>
</RelativeLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/darker_gray"
    android:orientation="vertical" >
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:src="@drawable/header_arrow" >
    </ImageView>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:gravity="center"
        android:orientation="vertical"
        android:paddingBottom="40dp" >
        <TextView
            android:layout_width="230dp"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:singleLine="false"
            android:text="@string/choose"
            android:textSize="24sp" />
        <FrameLayout
            android:layout_width="250dp"
            android:layout_height="250dp"
            android:layout_gravity="center"
            android:background="@android:color/white"
            android:gravity="center"
            android:orientation="vertical" >
            <android.support.v7.widget.CardView
                android:id="@+id/cv"
                xmlns:card_view="http://schemas.android.com/apk/res-auto"
                android:layout_width="200dp"
                android:layout_height="wrap_content"
                android:paddingLeft="25dp"
                android:background="@android:color/black"
                android:paddingRight="25dp"
                android:paddingTop="25dp" >
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/arabic"
                    android:textColor="@android:color/white" >
                </TextView>
            </android.support.v7.widget.CardView>
              <android.support.v7.widget.CardView
                android:id="@+id/cv1"
                xmlns:card_view="http://schemas.android.com/apk/res-auto"
                android:layout_width="200dp"
                android:background="@android:color/black"
                android:layout_height="wrap_content"
                android:paddingLeft="25dp"
                android:paddingRight="25dp"
                android:paddingTop="25dp" >
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/english"
                    android:textColor="@android:color/white" >
                </TextView>
            </android.support.v7.widget.CardView>
        </FrameLayout>
    </LinearLayout>
</LinearLayout>

我的代码有什么问题?为什么我在第 71 行的卡片视图上收到这样的错误。我仍然找不到解决方案,而我实现与教程相同。 如果可能,请提供帮助。我添加了一些属性,删除了一些。一遍又一遍没有影响和相同的错误

【问题讨论】:

    标签: android performance


    【解决方案1】:

    在 React-native 中,您需要在 gradle.build 中为 appcompat 强制使用相同的版本,

    configurations.all {
        resolutionStrategy {
            force 'com.android.support:appcompat-v7:23.4.0'
        }
    }
    

    【讨论】:

      【解决方案2】:

      您是否在模块的 build.gradle 文件中添加了 CardView 依赖项?确保你拥有它,因为它与你忘记包含它时遇到的异常相同。

      compile 'com.android.support:cardview-v7:21.0.+'
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-01-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-03
        • 1970-01-01
        相关资源
        最近更新 更多