0

各テーブル行の周囲に境界線があるテーブルがあります。一方の列のテキストが2行目に入るのに、もう一方の列のテキストはそうではない場合、境界部分に問題が発生します。これにより、2行目にテキストが折り返されていない行が短くなり、2行目の背景が黒になります。その行を他の行と同じ高さにするにはどうすればよいですか?

私のコードは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="#013567" >

    <TableLayout
        android:id="@+id/tableLayout1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:shrinkColumns="*"
        android:stretchColumns="*" >

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#000" >

        <TextView
            android:id="@+id/textView2"
            android:layout_margin="2dip"
            android:background="#013567"
            android:gravity="center"
            android:text="long text abc 123 ong tex ong tex"
            android:textColor="#fff" >
        </TextView>

        <TextView
            android:id="@+id/textView3"
            android:layout_margin="2dip"
            android:background="#013567"
            android:gravity="center"
            android:text="short text"
            android:textColor="#fff" >
        </TextView>
    </TableRow>

    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#000" >

        <TextView
            android:id="@+id/textView2"
            android:layout_margin="2dip"
            android:background="#013567"
            android:gravity="center"
            android:text="short text"
            android:textColor="#fff" >
        </TextView>

        <TextView
            android:id="@+id/textView3"
            android:layout_margin="2dip"
            android:background="#013567"
            android:gravity="center"
            android:text="long text abc 123 ong tex ong tex"
            android:textColor="#fff" >
        </TextView>
    </TableRow>
</TableLayout>
</ScrollView>

例: ここに画像の説明を入力してください

4

4 に答える 4

1

TextView次のプロパティをではなくに追加しTableRowます。

android:layout_height="match_parent"

また

android:layout_height="fill_parent"(非推奨)

于 2012-09-12T09:55:54.090 に答える
0

「短いテキスト」の en に新しい行を追加します

プログラムで:

  • \n

xml:

  • XMLコードでEnterキーを押すだけです
于 2012-09-10T22:57:28.533 に答える
0

これを修正するにはいくつかの方法がありますが、

で各テキストの周りに FrameLayout を追加しますandroid:layout_height="match_parent"

また

たとえば、スタイリングをテーブルに適用するように変更します。

Androidでテーブルレイアウトのスタイルを設定する方法

テーブルの背景を青に、境界線を黒に設定します。

于 2012-09-12T10:07:42.223 に答える
0

に次を設定してみてくださいTableRow

android:layout_height="fill_parent"
于 2012-09-09T13:48:04.483 に答える