我試圖讓三個按鈕彼此相鄰,左邊的一個和右邊的一個是小的,中間的一個應該填滿寬度的其餘部分 - 2x2dp(= margin) 。 我對以下代碼進行了編碼,但它不斷推動我的右鍵離開屏幕,關於如何解決此問題的任何想法?可能有辦法讓左邊的和右邊的都有效?謝謝!RelativeLayout:按鈕將其他按鈕從屏幕上移開
<RelativeLayout
android:id="@+id/rl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp" >
<Button
android:id="@+id/bPreviousQuestion"
android:layout_width="42dp"
android:layout_height="42dp"
android:background="#c8c8c8"
android:text="<"
android:textColor="#ffffff"
android:textSize="20dp"
/>
<Button
android:id="@+id/bBack"
android:layout_width="fill_parent"
android:layout_height="42dp"
android:layout_toRightOf="@+id/bPreviousQuestion"
android:background="#c8c8c8"
android:text="Go Back"
android:textColor="#ffffff"
android:textSize="20dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp" />
<Button
android:id="@+id/bNextQuestion"
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_toRightOf="@+id/bBack"
android:background="#c8c8c8"
android:text=">"
android:textColor="#ffffff"
android:textSize="20dp" />
</RelativeLayout>
不錯的山姆,謝謝!所以你確實可以通過讓它們取決於你在屏幕上「修復」的其他按鈕來實現按鈕的特權,謝謝! –
是的,通過試驗和錯誤,你會發現哪些屬性優先於其他屬性。例如,'layout_alignParent ____'是一個將視圖固定到某個位置的更加明確的屬性,而'toLeftOf'和'toRightOf'則是動態設計。你還會發現諸如'layout_center _____'這樣的屬性不會改變,它們將以其特定的軸爲中心。 – Sam