RelativeLayout的layout_marginBottom属性失效问题

最近项目中需要在右下角添加一个置顶按钮

部分布局如下

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/bg_gray">

    <ImageView
        android:id="@+id/iv_totop"
        android:layout_width="@dimen/x50"
        android:layout_height="@dimen/y50"
        android:layout_alignParentRight="true"
        android:layout_marginRight="@dimen/x30"
        android:layout_above="@+id/iv"
        android:layout_marginBottom="@dimen/y30"
        android:src="@drawable/to_top"
        android:visibility="gone" />
    <View
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:id="@+id/iv"
        android:layout_alignParentBottom="true"
        />
</RelativeLayout>

这个是最终版本  无效的版本就不展示了  

 

最后总结:
RelativeLayout布局里   最下面的控件 android:layout_alignParentBottom="true"和 layout_marginBottom属性无效,如果添加一个其他控件使用layout_above让自己处于最下面的控件之上,那么layout_marginBottom属性有效

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值