Android:对齐父级底部+底部边距

我使用了一个相对布局,我想把按钮设置在屏幕的底部,但是这会把它放在底部,我希望有一些边距,这样在屏幕/视图的末端和按钮之间会有一些空间。然而,无论我做什么,由于某种原因,按钮边距在2.1+上都不能做任何事情。相对布局包含一个背景,所以我只能在上面加上边距

有人知道解决办法吗

<?xml version=“1.0”encoding=“utf-8”?>
<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android"
android:layout\u width=“匹配父项”
android:layout\u height=“match\u parent”
android:layout_marginBottom=“0dp”
android:background=“@drawable/background”>
<按钮
android:id=“@+id/confirm\u mobile\u button\u next”
android:layout\u width=“fill\u parent”
android:layout\u height=“40dip”
android:layout\u alignParentBottom=“true”
android:layout\u alignParentLeft=“false”
android:layout\u centerHorizontal=“false”
android:layout\u centerInParent=“false”
android:layout_margin=“15dp”
android:background=“@drawable/button\u shape\u选择器”
android:paddingLeft=“10dip”
android:paddingRight=“10dip”
android:text=“@string/confirm\u mobile\u no\u continue”
android:textColor=“@color/white”
android:textStyle=“bold”/>
&lt/相对寿命>

您只需在RelativeLayout中添加一个填充,而不是在按钮上添加边距,例如,android:paddingBottom=“15dp”

一般来说,我总是使用API级别8设置在Exclipse预览中测试我的布局。这为大多数设备(包括IC和JB)提供了相当准确的结果

发表评论