我的xml代码中有一个错误,该错误会停止所有应用程序

问题描述 投票:0回答:1

我的我的代码有错误

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'androidx.cardview:cardview:1.0.0'

和用于xml

<android.support.v7.widget.CardView
            android:id="@+id/card_view"
            android:layout_width="match_parent"
            android:layout_height="293dp"
            app:cardBackgroundColor="@color/card"
            app:cardCornerRadius="10dp"
            app:cardElevation="5dp"
            app:cardUseCompatPadding="true">

            <TextView
                android:id="@+id/textView4"
                android:layout_width="432dp"
                android:layout_height="510dp"
                android:text="TextView" />

            <WebView
                android:id="@+id/webview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:ignore="WebViewLayout" />
        </android.support.v7.widget.CardView>

有了这行代码,应用程序停止了,我只尝试了依赖关系行,而我没有放置XML代码行,只有依赖关系实现cardview行和hid并没有停止,但是当我放行时应用程序停止的XML文件的代码集。

java android android-cardview
1个回答
0
投票

您的gradle文件中具有androidxCardView版本:

implementation 'androidx.cardview:cardview:1.0.0'

但是您在布局文件中使用的是旧版本的CardView

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

您必须在两个版本中使用相同的版本。因此,用以下代码替换布局文件中的标记:

<androidx.cardview.widget.CardView ... />
© www.soinside.com 2019 - 2024. All rights reserved.