我是靠谱客的博主 无私水壶,这篇文章主要介绍android 布局: LinearLayout如何使TextView中的内容居中显示,现在分享给大家,希望可以做个参考。


在LinearLayout布局中:

复制代码
1
2
3
4
5
6
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="#FFFFFF" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical">
在TextView中:
复制代码
1
2
3
4
5
6
7
<TextView android:id="@+id/tv_result" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="10dip" android:layout_gravity="center_horizontal" android:textSize="16sp" />

注意:

1、外部LinearLayout布局的方向是竖直方向;

2、layout_width 不能是fill_parent,layout_gravity 为水平居中;

如果不想这样做,也可以外层使用相对布局Relativelayout。





转载于:https://www.cnblogs.com/jinfenglee/p/4388730.html

最后

以上就是无私水壶最近收集整理的关于android 布局: LinearLayout如何使TextView中的内容居中显示的全部内容,更多相关android内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(62)

评论列表共有 0 条评论

立即
投稿
返回
顶部