如何在AndroidX的布局xml中添加cardview
升级到 AndroidX 后
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp">
给出一个错误
找不到以下类: - android.support.v7.widget.CardView(修复构建路径、编辑 XML、创建类)
dependencies {
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
但我不知道如何在AndroidX下的xml中使用CardView
谢谢
原文由 Jack Wilson 发布,翻译遵循 CC BY-SA 4.0 许可协议
班级已更改为:
如果你想使用旧的类名,你需要将
android:enableJetifier=true
添加到你的gradle.properties
并使用 appcompat 依赖。