<TableLayout xmlns:android="http://www.easck.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:stretchColumns="1"> ... </TableLayout>
TableRow: 代表表格布局的一行,行内一个元素代表一列。
layout_span: 合并单元格,设置为2,代表该元素占据2列空间。
stretchColumns: TableRow中无法指定空间宽度,那么需要用到该属性,设置为1,表示拉伸第2列(0为第1列)与屏幕一样宽,效果如TableLayout的第二张图。
5.自定义布局
Android中,布局下可以放置控件,也可以放置子布局。如果子布局内容较为独立且经常使用,例如标题栏,或者布局比较复杂,这时候可以考虑使用自定义布局的形式导入。方法很简单。
新建一个布局文件,例如example.xml
在父布局中引入:
<LinearLayout xmlns:android="http://www.easck.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/example"/> </LinearLayout>
以上就是Android最基本的四种布局的详细内容介绍,希望对大家的学习有所帮助。
注:相关教程知识阅读请移步到Android开发频道。










