这个程序很简单,只是在xml中布局并显示一个TextView
<TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text"
android:layout_width="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:text="@string/hello_world"/>android:layout_width="match_parent"控件宽度: 原来的属性叫fill_parent,后来SDK修改了名字,但是作用不变
android:gravity="center_vertical|center_horizontal"
对齐方式: 垂直,水平居中对齐。
可以使用 | 符号来设置多个属性
效果如下

本文介绍了一个简单的XML布局示例,展示了如何在Android应用中使用TextView进行文本显示,并详细解释了关键属性如控件宽度和对齐方式。

2454

被折叠的 条评论
为什么被折叠?



