Android中TextView的水平和垂直居中文本 [英] Horizontally and Vertically center text for TextView in Android
本文介绍了Android中TextView的水平和垂直居中文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Android中将TextView的文本水平和垂直居中? 如何居中对齐TextView?
How do I center the text horizontally and vertically for a TextView in Android? How do I center the alignment of a TextView?
推荐答案
在线性布局中使用
android:layout_gravity="center"
在相对布局中
android:layout_centerInParent="true"
以上代码将textView在布局中居中 将文本在TextView中居中
Above Code will center the textView in layout To center the text in TextView
android:textAlignment="center"
android:gravity="center"
这篇关于Android中TextView的水平和垂直居中文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文