2011-08-27 111 views

回答

63

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

2

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>