java - Cardview 未在 android studio 3.5.1 中显示
问题描述
我已经CardView
在较旧的 android studio 版本 3.3.1 上尝试了库,并且代码正在运行。模拟器显示正确的图像。但是,我切换到新版本 3.5 中没有显示任何内容CardView
,甚至没有显示TextView
.
xml代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:background="#fcfcfc"
android:gravity="center"
android:id="@+id/LinearLayout1">
<!-- A CardView that contains a TextView -->
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="200dp"
card_view:cardCornerRadius="4dp">
<TextView
android:id="@+id/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v7.widget.CardView>
</LinearLayout>
摇篮:
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 'com.android.support:cardview-v7:28.0.0'
}
解决方案
你应该使用
<androidx.cardview.widget.CardView //XML Section
添加AndroidX
依赖
implementation 'androidx.cardview:cardview:1.0.0'
推荐阅读
- docker - docker容器上的ffmpeg安装失败
- java - GridLayoutManager linearLayoutManager=new GridLayoutManager(ViewDeckPages.this,1,GridLayoutManager.HORIZONTAL,false); 不工作
- google-analytics - 本地调试时如何不向GA发送数据?
- sql - I have a table and i resultant output as I shown in description
- git - 运行 git 命令时未列出 Git 分支
- apache-kafka - KSQL 表 - 表连接未按预期工作
- php - 基于 MySQL 数据库生成新帖子 WordPress
- python - statsmodels 无法使用诸如登录异构类型行之类的函数来预测公式
- c# - 从 Dynamics365 代码活动返回自定义的 DTO 类
- java - 如何根据坐标空间获取 MySQL 8 中的对象列表