RelativeLayout中的TextView水平中心 [英] TextView horizontal center in RelativeLayout
本文介绍了RelativeLayout中的TextView水平中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用程序屏幕中,我想将标题"显示为水平居中.我尝试使用以下布局xml代码
In my app screen, i want to show Heading as horizontally center. I tried with below layout xml codes
<?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>
谢谢
推荐答案
android:gravity
控制TextView中的外观.因此,如果您有两行文本,它们将位于TextView的边界内.尝试android:layout_centerHorizontal="true"
.
android:gravity
controls the appearance within the TextView. So if you had two lines of text they would be centered within the bounds of the TextView. Try android:layout_centerHorizontal="true"
.
这篇关于RelativeLayout中的TextView水平中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文