在我的应用程序屏幕上,我想将方向显示为水平居中。我尝试使用下面的布局xml代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dip"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Connections" />
</RelativeLayout>
谢谢
发布于 2012-02-03 13:28:01
android:gravity
控制TextView中的外观。因此,如果您有两行文本,它们将在TextView的边界内居中。试试android:layout_centerHorizontal="true"
。
发布于 2012-02-03 13:28:11
使用以下命令:
android:layout_centerHorizontal="true"
在TextView中
发布于 2012-02-03 13:38:52
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dip"
>
<TextView
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Connections" />
</RelativeLayout>
https://stackoverflow.com/questions/9124075
复制相似问题