正如标题所说,刚刚下载的Android Studio和我有错误。我是Android dev和Kotlin的新手,我的activity_main.xml有四个错误,预览屏幕不工作。代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>错误:此处不允许使用属性android:layout_width此处不允许使用属性android:layout_height此处不允许使用属性工具:此处不允许使用上下文此处不允许使用元素TextView
如有任何帮助,我们不胜感激!
发布于 2019-11-25 12:16:46
如果以下任何一种解决方案对您有效,您可以尝试。
确保您的internet连接处于活动状态
1)只需转到文件->与Gradle文件同步项目
2)使缓存无效/重新启动->无效并重新启动
3)构建->重建项目
4)删除项目位置中的.idea文件夹,然后生成-> clean
发布于 2019-11-25 15:05:44
只需从文件导入项目,
文件->新建->导入项目-><选择您的项目>
这对我很有效
https://stackoverflow.com/questions/59024437
复制相似问题