我正在我的 textView 中寻找一些属性,例如 layoutCenteringParent,但找不到它们。我想找到该特定属性以使文本居中(我正在学习在线教程)。我试着听从这里的建议: Missing attributes in the layout design - Android Studio
并删除了我的 Android studio 缓存,但没有帮助。 我是初学者,所以很有可能我只是在这里遗漏了一些东西。我附上截图:
最佳答案
使用 ConstraintLayout,您应该从所有四个边约束 Textview
使其居中。
<?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>
关于android - textView 中缺少一些布局属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57475894/