[英]CardView and other views not showing in android studio layout editor
CardView 和其他视图未在 android 工作室布局编辑器中显示。我提供我的 Gradle、布局和布局编辑器视图详细信息。 请帮忙
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="380dp"
android:layout_margin="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="3"
android:padding="8dp"
android:text="Title"
android:textColor="#222"
android:textStyle="bold"
android:textSize="22dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:maxLines="3"
android:padding="8dp"
android:text="@string/description"
android:textColor="#666"
android:textSize="14dp" />
</RelativeLayout>
这是因为您在 androidx 中使用 android 支持,
在您的应用程序 gradle 中删除这些支持实现
implementation 'com.android.support:design:28:0.0'
implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
将您的 cardview 标签更改为androidx.cardview.widget.Cardview ,您似乎也忘记在您的帖子中关闭您的 cardview 标签
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="380dp"
android:layout_margin="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="3"
android:padding="8dp"
android:text="Title"
android:textColor="#222"
android:textStyle="bold"
android:textSize="22dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:maxLines="3"
android:padding="8dp"
android:text="awdawdawd"
android:textColor="#666"
android:textSize="14dp" />
</RelativeLayout>
</androidx.cardview.widget.CardView>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.