我想在中间使用三个按钮进行布局。我打算再添加右侧角球2个按键,但现在我试图使其与这3个使所有按钮具有相同的尺寸
这项工作是我脑子里想的:
在某些方面,它应该在每个屏幕尺寸都相似(所以随着屏幕尺寸变小,按钮变小)。
现在,这是我所:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/multiplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/menubutton"
android:text="@string/multiplayer" />
<Button
android:id="@+id/options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/multiplay"
android:layout_below="@+id/multiplay"
android:background="@drawable/menubutton"
android:text="@string/options" />
<Button
android:id="@+id/singleplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/multiplay"
android:layout_alignLeft="@+id/multiplay"
android:background="@drawable/menubutton"
android:text="@string/singleplayer"
/>
看起来好像没什么大屏幕上,但在一个较小的这种情况:
我身边有一派,和大多数页面建议使用“重量”,但显然只适用于线性布局。有什么建议?
感谢
什么是不使用线性布局的原因是什么? –
为此使用线性更好吗? – Marshall
考虑到你只是试图把3个按钮放在eachother之上,是的,最好使用LinearLayout。您仍然可以使用RelativeLayout作为整体布局(这样您可以稍后在右上角添加这些按钮),但在中间使用3个按钮的LinearLayout。 –