我试图让三个按钮彼此相邻,左边的一个和右边的一个是小的,中间的一个应该填满宽度的其余部分 - 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