与TableLayout跨越列

问题描述:

可能重复:
What is the equivalent of “colspan” in an Android TableLayout?与TableLayout跨越列

它说,在文档中的TableLayout “细胞可以跨越列,因为它们可以在HTML”但是,我找不到任何方式来这样做。

具体来说,我有一列两列,另一列有一列。我想要一列行跨越整个表。看起来很简单,但我看不到它。

+1

重复的:http://stackoverflow.com/q/2710793/165674 –

添加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> 
+3

稀释,它就在那里,在TableRow.LayoutParams:http://developer.android.com/引用/ android/widget/TableRow.LayoutParams.html –

+2

查找这些布局XML文件非常棘手 - 容易忘记android:layout_ *属性位于单独的javadoc中。 –

+1

-1,该按钮的文字太小时,此解决方案不起作用。例如,当文本只是一个像计算器应用程序中的“+”时,该按钮将不会增长,直到它覆盖两列(如果这两列比按钮更宽而没有columnSpan)。 – Zelphir

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>