Android之Table Layout详解

2010-08-30 11:13:20 作者:jezz 资深编辑 有2518人浏览 网友评论 1
表格布局以表格行为基础,行内的一个UI元素为1列,可以设置一个UI元素跨多了在使用layout_span的属性。
TableLayout - 表格式布局。
TableRow - 表格内的行,行内每一个元素算作一列
collapseColumns - 设置 TableLayout 内的 TableRow 中需要隐藏的列的列索引,多个用“,”隔开
stretchColumns - 设置 TableLayout 内的 TableRow 中需要拉伸(该列会拉伸到所有可用空间)的列的列索引,多个用“,”隔开
shrinkColumns - 设置 TableLayout 内的 TableRow 中需要收缩(为了使其他列不会被挤到屏幕外,此列会自动收缩)的列的列索引,多个用“,”隔开
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:id="@+id/tablelayout1"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:collapseColumns="0,3">
  <TableRow>
      <TextView android:text="URL:"/>
      <EditText android:id="@+id/url"
               android:layout_span="3"/>
 </TableRow>
 <View
     android:layout_height="2px"
     android:background="#0000FF" />
   <TableRow>
     <Button android:id="@+id/cancel"
       android:layout_column="2"
       android:text="Cancel" />
     <Button android:id="@+id/ok"
       android:text="OK" />
   </TableRow>
 </TableLayout>

注意到EditText控件和ok按钮控件的列索引属性。因为EditText跨了3列,所以被隐藏了。
tableLayout.png
  • 共有 1 位网友发表了评论
  • 1 楼 网友:222.66.*.* 于 2010-08-30 11:14:47 评论道: 引用
  • table layout对每列固定宽度有不错的效果。
看不清,换一张请输入验证码: (登录注册用户不用填验证码)

热门新闻

  • 没有热门新闻

热评推荐

  • 没有热评推荐
网盟新闻广告