屏幕中央的TextView [重复]
Possible Duplicate:
How do I center text horizontally and vertical in a TextView in Android?可能重复:如何在Android中的TextView中水平和垂直居中文本?
I have a RelativeLayout
(before it was a LinerLayout
), that occupies all the screen and I want to put in the center of this Layout
, a TextView
. I try to do it with gravity = "center"
layout_gravity = "center"
and a few more, but it doesn't work.
我有一个RelativeLayout(在它是一个LinerLayout之前),占据了所有的屏幕,我想放在这个布局的中心,一个TextView。我试着用gravity =“center”layout_gravity =“center”和其他几个来做,但它不起作用。
Anybody knows how to center the TextView
in the middle of the screen?
有谁知道如何将TextView置于屏幕中间?
EDIT
Ok, I think I explained badly. I think the TextView
is in the center, but what I want to center is the text in the TextView
. Can I do this?
好吧,我想我解释得很糟糕。我认为TextView位于中心,但我想要的中心是TextView中的文本。我可以这样做吗?
9 个解决方案
#1
55
If your font size is big enough, it might look like it's not centered, because of the font padding.
Try using the already mentioned properties combined with android:includeFontPadding
, something like this:
如果你的字体大小足够大,它可能看起来没有居中,因为字体填充。尝试使用已经提到的属性结合android:includeFontPadding,如下所示:
android:gravity="center"
android:includeFontPadding="false"
更多相关文章
- 将常量文本放在EditText中,这应该是不可编辑的——Android
- Java - 检查所有行中现有文本的.txt
- 关于LSA的相关学习---短文本聚类涉及到的知识,一种主题模型(原载于
- 请问用Java如何逐行的读取一个文本文件呀?我现在只能完整读取.
- 怎么在html,Javascript,vBscript中实现从网页上接收数据存入文本
- 帮忙解析一下 java解析普通的文本文件,提取信息到execl文件中
- 基于内容估计文本宽度的算法
- 如何修改JTextField (Swing)以显示在用户输入文本之前不会消失的
- spring cloud(学习笔记)高可用注册中心(Eureka)的实现(二)