RelativeLayout

RelativeLayout顾名思义就是根据各个控件之间的关系进行布局

和容器间的关系:
android:layout_alignParentTop

says the widget's top should align with the top of the container


android:layout_alignParentBottom

says the widget's bottom should align with the bottom of the container


android:layout_alignParentLeft

says the widget's left side should align with the left side of the container


android:layout_alignParentRight

 says the widget's right side should align with the right side of the container


android:layout_centerHorizontal

says the widget should be positioned horizontally at the center of the container


android:layout_centerVertical

says the widget should be positioned vertically at the center of the container


android:layout_centerInParent

says the widget should be positioned both horizontally and vertically at the center of the container

 

以上各个属性的值都为boolean值类型

当你需要引用另外一个控件的属性值时,可通过@id/widget_a.property进行引用

 

和其他控件间的关系:

android:layout_above

indicates that the widget should be placed above the widget referenced in the property


android:layout_below

indicates that the widget should be placed below the widget referenced in the property


android:layout_toLeft

indicates that the widget should be placed to the left of the widget referenced in the property


android:layout_toRight

 indicates that the widget should be placed to the right of the widget referenced in the property

 

android:layout_alignTop

 indicates that the widget's top should be aligned with the top of the widget referenced in the property


android:layout_alignBottom

indicates that the widget's bottom should be aligned with the bottom of the widget referenced in the
property


android:layout_alignLeft

indicates that the widget's left should be aligned with the left of the widget referenced in the property


android:layout_alignRight

 indicates that the widget's right should be aligned with the right of the widget referenced in the property


android:layout_alignBaseline

indicates that the baselines of the two widgets should be aligned

 

假如我们需要将控件B放在控件A的右边,我们可以这样进行设置

在控件B上写上:android:layout_toRight ="@id/widget_a"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值