我使用了相对布局,想将按钮设置在屏幕底部。但是这会把它放到底部,我希望在屏幕/视图的末尾和按钮之间留出一些空间。但无论我怎么做,按钮的外边距在2.1+上似乎都没有用。由于相对布局包含背景,所以我不能在其上设置外边距。
有人知道解决方法吗?
<?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"
android:layout_marginBottom="0dp"
android:background="@drawable/background" >
<Button
android:id="@+id/confirm_mobile_button_next"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="false"
android:layout_centerHorizontal="false"
android:layout_centerInParent="false"
android:layout_margin="15dp"
android:background="@drawable/button_shape_selector"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:text="@string/confirm_mobile_no_continue"
android:textColor="@color/white"
android:textStyle="bold" />
</RelativeLayout>
TextView
,并使用android:layout_alignParentBottom="true"
设置所需的高度,在上面放置所需的对象(在本例中是Button
)。 - cosmincalistruButton
中尤其明显,因为layout_height
定义了内容高度 + 填充。更多信息请参见:https://dev59.com/x2445IYBdhLWcg3w7urD#4619943 - Jin