二进制XML文件第一行:解压类错误<unknown>。现在该怎么办?

4
android:text="Hello World"的预览未显示,现在应该怎么做才能解决?
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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"
    tools:context=".MainActivity">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World"
        android:textColor="red"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout> 

你在 gradle 文件中添加了必要的依赖吗? - Phantômaxx
1个回答

1

1. 首先,在您的activity_main.xml布局中将android.support.constraint.ConstraintLayout替换为androidx.constraintlayout.widget.ConstraintLayout

2. 其次,进入app.gradle并添加依赖项implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

enter image description here

并按“立即同步”


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接