0

ボタンの高さを設定するのに問題がありますが、エミュレーターが望ましく表示されている間 (ボタンが狭い)、電話デバイス S2 で実行されています (ボタンが正方形になります)。エミュレーターのようにボタンが狭く表示されるように正しく設定するにはどうすればよいですか?

ボタンを textSize = 1dp で wrap_content に設定すると、エミュレーターはこの変更を非常に狭いボタンとして正しく反映して表示しますが、S2 で実行するとまだ正方形として表示されます。

実際のデバイスで正常に実行する方法を知っている人はいますか? どうもありがとう!!!

エミュレータ:

ここに画像の説明を入力

電話デバイス:

ここに画像の説明を入力

レイアウト コード:

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/light_blue"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/colorBlackBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="1dp"
            android:layout_weight="1"
            android:background="@drawable/black_btn" />

        <Button
            android:id="@+id/colorWhiteBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="1dp"
            android:layout_weight="1"
            android:background="@drawable/white_btn" />

        <Button
            android:id="@+id/colorRedBtn"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:textSize="1dp"
            android:layout_weight="1"
            android:background="@drawable/red_btn" />

        // same for other buttons 

    </TableRow>
4

1 に答える 1

2

を使用しLinearLayout、各ボタンに のheight(列または行の場合は幅) を指定し0px、 を使用android:layout_weightしてそれらの間にパーセンテージ ベースでスペースを割り当てます。この手法の概要を示すサンプルプロジェクトを次に示します。

于 2013-02-11T08:04:00.643 に答える