我想在中間使用三個按鈕進行佈局。我打算再添加右側角球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。 –