布局的初步介绍。包含布局的基础属性上的知识点
例如:id,text,textSize,background等等
包含如下布局介绍:
LinearLayout
TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
属性 | 含义 | 解释 |
---|
android:id=”@+id/text” | | |
android:layout_width=”fill_parent” | 宽度 | |
android:layout_height=”wrap_content” | 高度 | |
android:layout_weight=”1” | 权重 | 决定和其他控件所占空间比例 |
android:text=”文本text” | 文本 | |
android:textSize=”35pt” | text大小 | pt 像素单位中的标准长度单位 |
android:background=”#aabbcc” | | RRGGBB 分别为三原色 |
android:gravity=”center_vertical” | 空间内容所处的位置 | 居中等 |
android:padding=”30dip” | 内边距 | dip与像素无关、适应性好 |
android:singleLine=”true” | 内容是否在同一行 | 为“false”可能会占据下面控件空间,“true”多余内容显示为… |
- 属性 android:stretchColumns=”0”: 将第0列拉伸(与数组下标类似), 1:拉伸第1列(col)
<TableLayout
android:stretchColumns="0"
...>
<TableRow
...>
<TextView ... /> 控件11
<TextView ... /> 控件12
</TableRow>
<TableRow
...>
<TextView ... /> 控件21
<TextView ... /> 控件22
</TableRow>
</TableLayout>