我有兩個按鈕,我想水平並排顯示,但它們一起填滿了手機的水平長度。高度是包裝內容,沒關係。我現在的問題是隻有一個按鈕顯示出來(橫跨屏幕)。Android按鈕佈局 - 在整個屏幕上並排獲取兩個按鈕
這裏是我的XML代碼:
<LinearLayout
android:id="@+id/page_buttons"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
>
<Button
android:id="@+id/prevButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Previous"
/>
<Button
android:id="@+id/nextButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Next"
/>
你究竟如何期待兩個按鈕出現在屏幕上,因爲你已經在xml中指定了一個按鈕?你是否動態創建第二個並將其添加到線性佈局? – asenovm
我編輯了這篇文章,使其現在可讀。 – JDS