【发布时间】:2011-08-27 05:57:07
【问题描述】:
可能重复:
What is the equivalent of “colspan” in an Android TableLayout?
它在 TableLayout 的文档中说“单元格可以跨列,就像它们在 HTML 中一样。”但是,我找不到任何方法。
具体来说,我有一行两列,另一行一列。我希望一列行跨越整个表格。看起来很简单,但我没看到。
【问题讨论】:
标签: android android-tablelayout
可能重复:
What is the equivalent of “colspan” in an Android TableLayout?
它在 TableLayout 的文档中说“单元格可以跨列,就像它们在 HTML 中一样。”但是,我找不到任何方法。
具体来说,我有一行两列,另一行一列。我希望一列行跨越整个表格。看起来很简单,但我没看到。
【问题讨论】:
标签: android android-tablelayout
添加 android:layout_span="3" 以跨越 3 列。 例如:
<TableRow>
<Button android:id="@+id/item_id"
android:layout_span="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="item text" />
</TableRow>
【讨论】:
+ 时,按钮将不会增长,直到它覆盖两列(如果这两列比没有 columnSpan 的按钮宽)。
android:layout_span 可以解决问题。
示例:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
<TextView android:id="@+id/info"
android:layout_span="2"
android:text="some text"
android:padding="3dip"
android:layout_gravity="center_horizontal" />
</TableRow>
<TableRow>
<TextView android:text="some other text"
android:padding="3dip" />
<TextView android:text="more text"
android:padding="3dip" />
</TableRow>
</TableLayout>
【讨论】: