text查看相对位置中的水平中心

在我的应用程序屏幕中,我想将标题显示为水平居中。我尝试了以下布局xml代码

<?xml version=“1.0”encoding=“utf-8”?>
<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android"
android:layout\u width=“fill\u parent”
android:layout\u height=“fill\u parent”
android:layout_marginTop=“10dip”
&燃气轮机;
<文本框
android:layout\u width=“包装内容”
android:layout\u height=“包装内容”
android:gravity=“居中水平”
android:text=“Connections”/>
&lt/相对寿命>

谢谢

android:gravity控制文本视图中的外观。因此,如果有两行文本,它们将在TextView的边界内居中。</centeru=“Try-layout”试试水平布局

发表评论