これを実現するために、RelativeLayout と Linearlayout の両方を使用しました (画像内)!
相対レイアウトを使用して、ボタンを固定幅で、marginLeft と marginRight で配置しました。問題は、デバイスの画面が大きい場合、左右のマージンがあまり拡大されず、ボタンの幅も固定されることです。
<RelativeLayout> <!-- Row1 --> <Button1 alignParentTop = "true" marginLeft = "5dip" marginRight="5dip" width="80dip"/> <button2 alignParentTop ="true" center="@id/Button1" marginLeft = "5dip" marginRight="5dip" width="80dip" /> <button2 alignParentRight="true" marginLeft = "5dip" marginRight="5dip" width="80dip"/> <!-- Row2 --> <Button3 below="button1" marginLeft = "5dip" marginRight="5dip" width="80dip"/> <Button4 below="button2" marginLeft = "5dip" marginRight="5dip" width="80dip"/> </RelativeLayout>
RelativeLayout の親を使用して、ボタン付きの 2 つの水平方向の線形レイアウトを作成しました。ボタンの幅が 0dip で重みが 1 になりました。ただし、2 行目を作成できません。
<RelativeLayout>
<linearLayout orientation="horizontal">
<!-- Row1 -->
<Button1
width="0dip"
weight="1"/>
<button2
width="0dip"
weight="1"/>
<button2
width="0dip"
weight="1"/>
</linearLayout>
<!--Row2-->
<linearLayout orientation="horizontal">
Couldn't using this approach
</linearLayout>
</RelativeLayout>