Android textView中缺少一些布局属性

Android textView中缺少一些布局属性,android,android-layout,android-constraintlayout,Android,Android Layout,Android Constraintlayout,我正在文本视图中查找某些属性,如layoutCenteringParent,但找不到它们。我想找到那个特定的属性,以便将文本居中(我正在学习一个在线教程)。我试着按照这里的建议: 并删除了我的Android studio缓存,但没有任何帮助。 我是一个初学者,所以我很有可能错过了一些东西。我正在附上一张截图: 使用ConstraintLayout,您应该从四面对其进行约束,使其居中 <?xml version="1.0" encoding="utf-8"?> <android

我正在文本视图中查找某些属性,如layoutCenteringParent,但找不到它们。我想找到那个特定的属性,以便将文本居中(我正在学习一个在线教程)。我试着按照这里的建议:

并删除了我的Android studio缓存,但没有任何帮助。 我是一个初学者,所以我很有可能错过了一些东西。我正在附上一张截图:


使用ConstraintLayout,您应该从四面对其进行约束,使其居中

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="ABC"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    </androidx.constraintlayout.widget.ConstraintLayout>

您最好的选择是使用
ConstraintLayout
,如下所示:



要居中文本的容器,请将所有约束设置为父约束,并删除任何偏差。
要使容器内的文本居中,请使用android:gravity=“center”

将文本视图放置在何处?请单击顶部的推断约束图标。看起来像魔术棒。让我知道我的答案对你有用吗?