2012-04-19 16 views
3

私はTableLayoutに現在3行あり、各行には1人の子供、TextViewがあります。私の問題は、TextViewsの幅は"match_parent"ではありません。私はそれらの高さと幅を定義しない手順(like the documentation says)に従っていますが、なんらかの理由で問題が残っています。Android TableRowの子供の問題

私はを開いて値を調べましたが、TableRowは幅を塗りつぶしますが、TextViewは行を埋めるものではなく、内容をラップしています。完全なXMLレイアウトは以下の通りですが、他のアイデアはありますか?

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<TableRow 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
    <TextView 
     android:background="@drawable/textlines" 
     android:text="@string/text1_string" 
     android:textColor="#000000" 
     android:padding="5dp"> 
    </TextView> 
</TableRow> 
<TableRow 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
    <TextView 
     android:background="@drawable/textlines" 
     android:text="@string/text1_string" 
     android:textColor="#000000" 
     android:padding="5dp"> 
    </TextView> 
</TableRow> 
<TableRow 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
    <TextView 
     android:background="@drawable/textlines" 
     android:text="@string/text1_string" 
     android:textColor="#000000" 
     android:padding="5dp"> 
    </TextView> 
</TableRow> 
</TableLayout> 

また、私は@drawable/textlinesのためのxmlファイルが含まれます。おそらく問題はそこにありますか? (textlinesのコードは、ここで境界線に関する質問に関して提供された解決策から取られています)私はそれをかなり理解していますが、私の問題に影響するとは思えませんが、間違っている可能性があります。とにかく、ここにある:それはなぜ起こるか私にはわからないが、あなたが追加することによって、その問題のいずれかを避けることができ

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
<item> 
    <shape 
    android:shape="rectangle"> 
     <stroke android:width="1dp" android:color="#FF000000" /> 
     <solid android:color="#FFDDDDDD" /> 

    </shape> 
</item> 

<item android:top="1dp" android:bottom="1dp"> 
    <shape 
    android:shape="rectangle"> 
     <stroke android:width="1dp" android:color="#FFDDDDDD" /> 
     <solid android:color="#00000000" /> 
    </shape> 
</item> 
</layer-list> 

答えて

13

:、または追加することによって、あなたの子供TextView sの

android:layout_weight="1" 

を:

android:stretchColumns="0" 

とあなたの親のTableLayout。 `アンドロイド:私はあなたが意味を考える

+0

のTextViewにlayout_weight = "1"' を... DanDar3 @ –

+1

はい、1に幅を設定することは何も解決しません。あなたがそれを訂正できると思うなら、質問/回答を編集することを恐れてはいけません。 – Luksprog

+0

すべての列を処理するため*プログラムで* setStretchAllColumns(true)を使用します。 –

関連する問題