Hello World例子是一个基本的屏幕显示Activity的例子。主要是XML部分:
<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"/>
- 包含一个简单的TextView。
- android:layout_width定义了元素的宽,match_parent的意思是尽量填充它的上一层的宽,还有一个wrap_content,意思是自适应元素的宽度,也就是元素内容多宽它就多宽;layout_height类似。
- android:gravity定义元素的对齐方式,这里是水平居中,并且垂直居中。