2011-01-07 19 views
4

私はデータを表示するためにTableLayoutを使用しています。 アクティビティがonCreate()を呼び出すときに、右側の列のTextViewのテキストが設定されます。Android TableLayoutの幅の問題

ここで、私のアドレステキストが長くなる可能性があり、それをラップする必要があることがわかります。 だから私はandroid:layout_width="wrap_content"と設定しました。それでもデータをラップするには画面サイズの幅が必要です。 この問題を解決するにはどうすればよいですか?

alt text

私のxml:TableLayoutにandroid:shrinkColumns="1"を追加

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:padding="5px"> 
    <TableRow> 
     <TextView android:text="Job#" 
      android:paddingRight="5px" /> 
     <TextView android:id="@+id/DetailJobNo" /> 
    </TableRow> 
    <TableRow> 
     <TextView android:text="Address" 
      android:paddingRight="5px" /> 
     <TextView android:id="@+id/DetailAddress" 
      android:layout_width="wrap_content" 
      android:text="Address Address Address Address Address Address Address Address "/> 
    </TableRow> 
</TableLayout> 

答えて

6

は私の問題を解決します。

0

@Vikas、あなたの問題を解決したことは良いことです。

私はまだセキュリティの目的でHorizo​​ntalScrollViewを使用することをお勧めします。少数の文字がすべて表示されない場合は、水平スクロールバーがそれを管理するのに役立ちます。 XMLテキスト:

<HorizontalScrollView android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="10dp" android:layout_marginBottom="10dp" > 

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:padding="5px"> 
    ...... 
    ...... 
    ADD YOUR ROWS 
</TableLayout>  
</HorizontalScrollView> 

予期しないことを常に処理する方が良い。