安卓开发中为什么文本不居中?(语言-java)

模拟器文本不居中

img

以下是报错
We recommend using a newer Android Gradle plugin to use compileSdk = 32

This Android Gradle plugin (7.0.4) was tested up to compileSdk = 31

This warning can be suppressed by adding
android.suppressUnsupportedCompileSdk=32
to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdk = 32
翻译过后也是理解不了

我想要模拟器呈现的效果与我在代码里面一致

约束布局

百度一下constraintlayout的用法 布局写的不对

TextView需要加四个属性
startToStart=“parent"
endToEnd=“parent"
topToTop=“parent"
marginToStart="180"

再把你现在写的那两行absolute删掉


楼主还是百度下ConstrainLayout用法吧

ConstrainLayout布局方式的控件居中方式去搜一下。
或者使用线性布局,用相应的控件居中,内容居中属性即可