2010-03-02 36 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