2010-03-02 34 views
4

我嘗試了這種表格佈局,其中有三列,每列利用最大空間,因爲他們可以(使用strechColumn標籤)。現在,當某列的內容過長時,表格佈局會跳出屏幕。我們如何設置一個列的內容來包裝在表格佈局

如何設置要換行的列的內容,以便表格佈局不會跳出屏幕。

這裏是表格佈局的XML代碼,我用

<?xml version="1.0" encoding="utf-8"?> 

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:scrollbars="vertical" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent"> 

    <TableLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:stretchColumns="0,1,2" 
     android:id="@+id/tLayout" 
     android:scrollbars="vertical" 
     > 
     <TableRow 
      android:layout_width="fill_parent"> 
      <TextView 
       android:padding="3dip" 
       android:gravity="left" 
       android:text="Name" 
       /> 
      <TextView 
       android:padding="3dip" 
       android:gravity="left" 
       android:text="Address" 
       /> 
      <TextView 
       android:padding="3dip" 
       android:gravity="left" 
       android:text="Age" 
       /> 
     </TableRow> 
    </TableLayout> 
</ScrollView> 

回答

6

有一個相應的android:shrinkColumns,你可以在你的TableLayout指定。

+1

如果你想通過代碼來做:'tblLyt.setColumnShrinkable(1,true);' – ankitjaininfo 2010-08-08 18:59:51