0

Androidの画面の画面サイズに合わせて3つのボタンを並べて設定するにはどうすればよいですか。画面の 50% 50% の場合、これが使用されます。しかし、3番目のボタンを追加したい場合、どうすればこれを達成できますか。つまり、35% 35% 35% と 5% のスペースです。

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_height="wrap_content"
 android:layout_width="fill_parent"
 android:orientation="horizontal"
 android:weightSum="1.0">
 <Button
  android:id="@+id/textbox3"
  android:layout_height="wrap_content"
  android:layout_weight=".5"
  android:layout_width="0dip"
  android:textSize="12sp" />
</LinearLayout>
4

1 に答える 1

0

それを行うことを忘れないでください2つのポイント

  1. 3つのボタンはすべて、layout_weightとで同じ(例:1)の値を持つ必要があります
  2. shoudlのlayout_heightとlayout_widthは同じです

以下に示すように

<?xml version="1.0" encoding="utf-8"?>`enter code here`
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

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

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

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

</LinearLayout>
于 2013-03-01T06:38:40.093 に答える