2010-12-04 67 views
19

正在学习Android和我在努力让我解决这个特定布局属性头,读谷歌的开发文档,它说:android:layout_column做什么?

android:layout_column 

列的索引中,这个孩子应该是。必须是 整数值,例如“100”。这也可能是对 资源(形式为“@ [package:] type:name”)或主题属性(以 形式“?[package:] [type:] name”)的引用,其中包含值这个类型。 这对应于全局属性资源符号 layout_column。

任何人都可以解释这是如何映射到一个html等效(如表行似乎从他们大量借用)?

它是否支持比如colspan?

回答

25

呃,它的意思是“这个孩子应该在哪一列的索引”。唯一棘手的部分是,在列0

启动例如:

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:stretchColumns="1"> 
    <TableRow> 
     <TextView 
       android:text="URL:" /> 
     <EditText android:id="@+id/entry" 
      android:layout_span="3"/> 
    </TableRow> 
    <TableRow> 
     <Button android:id="@+id/cancel" 
      android:layout_column="2" 
      android:text="Cancel" /> 
     <Button android:id="@+id/ok" 
      android:text="OK" /> 
    </TableRow> 
</TableLayout> 

在上述布局两个行有四列。第一个列有四列,因为它在第0列中有TextView,第1列和第2列中有EditText。第2列有四列,因为它跳过列0和列1,并将两个Button小部件放在第2列和第3列中,在第一个Button中提供android:layout_column="2"属性。

+1

啊,这是有道理的 - 然后没有遵循,因为HTML不能以这种方式与基于索引的表一起工作,它默认情况下'假设'每个​​的宽度。 – Alphatester77 2010-12-04 23:33:45