次のレイアウトを達成したいと思います。私は、ボタンの残りの部分にあるボタン0を等しくするにはどうすればよいすべてのボタンの幅が同じ
。 layout_weight = "1"
を使用して、残りのボタンのすべてが同じ長さで親に一致するようにしています。以来、私は別のレイアウトでボタン0を作成したので、他のボタンと同じ長さにすることはできません。
ここに私のコードは
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/seven"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content" />
<Button
android:id="@+id/eight"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content" />
<Button
android:id="@+id/nine"
android:layout_gravity="center_horizontal"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/zero"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
作成ボタン "0"の側には見えない2つの "ダミー"ボタンがあります。しかし、LinearLayoutsの代わりにGridViewを使用することをお勧めします。 –