1. 失效的原因
当在外层layout属性设置为android:layout_height="wrap_content"时,最下面的控件layout_marginBottom属性无效
2. 解决办法
2.1. 设置属性为android:layout_height="match_parent"或固定值
2.2. 在最外层的RelativeLayout中设置android:paddingBottom=“xxdp”
2.3. 在RelativeLayout下面再加一个0dp的view
如果其他控件使用layout_above或其他办法让自己处于最下面的控件之上,那么layout_marginBottom属性有效。
<View
android:id="@+id/test"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_alignParentBottom="true"/>
2.4. 使用layout_below
适用场景:当有多个view竖向排列时
android:layout_alignParentBottom="true"
android:layout_below="@+id/xxx"