android-studio - 为什么我的设计屏幕是灰色的,并且在 Android Studio 中只显示“androidx.constraintlayout.ConstraintLayout”?
问题描述
我正在尝试通过 CodingInFlow 在 YouTube 上关注 Android Studio 开发的播放列表。
我正在尝试观看此视频,但遇到问题... https://www.youtube.com/watch?v=-sPOtGqd5OA&list=PLrnPJCHvNZuBtcos16XJnfFx2fSUOyW_-&index=9
我的设计屏幕只是显示为一个灰色框,我收到“androidx.constraintlayout.ConstraintLayout(找不到类)”的错误。
在视频中,他没有使用 AndroidX,而且他的开始标签与我在 .xml 文件中的标签不同。
他的 .xml 文档的开始标签:android.support.constraint .ConstraintLayout
我的 .xml 文档的开始标签:androidx.constraintlayout .ConstraintLayout
我该如何解决这个问题,以便设计显示当前灰色框所在的位置?
谢谢
解决方案
可能是您缺少它的库并且无法识别。
打开你的 build.gradle (app) 并添加:
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
关于“androidx”库的视频有点旧,所以这就是他的标签与你的不同的原因。所以你必须添加支持它的库。
推荐阅读
- c# - 在 asp.net core signalR 1.1.0 中找不到集线器参考?
- node.js - 在 ews-javascript-api 或应用程序中处理 ErrorExceededConnectionCount?
- rust - 为什么在调用一个通过值获取 self 的方法时会借用一个移动值,而该方法的参数也调用一个方法?
- node.js - 如何在collector.on('end',...)中获取'原因'
- primes - 现在安装的 C 编译器如何导入数论函数?
- sed - 使用 sed 更改模式仅用于匹配 df 文件中的行
- python - Python Portable + Geany Portable - “程序以代码 0 退出”
- r - 从特定列开始并根据 R 中的条件遍历特定数量的列
- c# - c# do while unassigned局部变量问题
- c# - 如何使用 C# 更新数据库/表并在 GridView 中即时显示更改?