查阅了一些博文,说 在无效 控件的下面再写一个View等等,发现还是没有作用。
我的方法:
如在下面的xml中,我想设置Button 距离屏幕底部的距离为90dp;
1. 写一个没有内容的TextView,设置属性为layout_alignParentBottom="true",将其高度设置为 90dp;
2.在Button中设置 android:layout_alignTop="@+id/nousetv",将Button的底部与TextView的顶部对齐。
这样就间接的达到了 android:layout_alignBottom="90dp" 的效果。
<?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" >
<ImageView
android:id="@+id/iv_start"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/logo_start" />
<TextView
android:id="@+id/nousetv"
android:layout_width="fill_parent"
android:layout_height="90dp"
android:layout_alignParentBottom="true" />
<Button
android:id="@+id/retrybtn"
android:layout_width="100dp"
android:layout_height="38dp"
android:layout_centerHorizontal="true"
android:background="@drawable/bg_normal"
android:layout_alignTop="@+id/nousetv"
android:text="重试一下"
android:textColor="#fff"
android:textSize="16dp"
android:visibility="visible" />
</RelativeLayout>