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" >

    <TableRow>

        <Button
            android:id="@+id/button1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="ABCDE" />

        <Button
            android:id="@+id/button2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="A" />

        <Button
            android:id="@+id/button3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="ABC" />
    </TableRow>

</TableLayout>

ここに画像の説明を入力

ボタンは同じlayout_weightですが、幅が異なります。なぜそれらは同じ幅を占めていないのですか? (ピクセル値を指定せずに) 幅を等しくするにはどうすればよいですか?

4

2 に答える 2

3

に変更layout_widthする0dipと、問題が修正されます。

これが機能する理由または使用する理由の詳細については、この説明を確認してください。

お役に立ててうれしいです。

于 2012-12-20T17:15:21.367 に答える
2

に設定できますlayout_width0dip、テキストが長すぎるとあまり良くありません。

于 2012-12-20T17:15:07.560 に答える