2011-12-23 25 views
8

我正在开发一个使用TableLayout的屏幕。在这里我可以轻松创建两列。但我如何创建三列?如何在TableLayout中创建三列

+2

究竟添加另一列以同样的方式像你一样添加两列 – 2011-12-23 12:47:46

回答

14

下面的例子:

<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="first" 
      android:padding="3dip" /> 
     <TextView 
      android:text="second" 
      android:gravity="center" 
      android:padding="3dip" /> 
     <TextView 
      android:text="third" 
      android:gravity="right" 
      android:padding="3dip" /> 
    </TableRow> 

    <TableRow> 
     <TextView 
      android:text="first" 
      android:padding="3dip" /> 
     <TextView 
      android:text="second" 
      android:gravity="center" 
      android:padding="3dip" /> 
     <TextView 
      android:text="third" 
      android:gravity="right" 
      android:padding="3dip" /> 
    </TableRow> 
</TableLayout> 
+0

@Lucifer我想你应该给予好评,以他们的努力,如果你还找到了自己的答案有帮助。 – 2011-12-26 06:47:17

+0

要为所有列设置固定的等宽,请参阅此处:http://stackoverflow.com/a/6647298/261436 – Sam 2015-12-11 21:51:11

2

对于每个TableRow,你必须添加三个孩子而不是两个。这应该是适合你的!

希望这会有所帮助!

相关问题