相对布局常用属性:

子类控件相对子类控件:值是另外一个控件的id

android:layout_above----------位于给定DI控件之上
android:layout_below ----------位于给定DI控件之下

android:layout_toLeftOf -------位于给定控件左边
android:layout_toRightOf ------位于给定控件右边

android:layout_alignLeft -------左边与给定ID控件的左边对齐
android:layout_alignRight ------右边与给定ID控件的右边对齐
android:layout_alignTop -------上边与给定ID控件的上边对齐
android:layout_alignBottom ----底边与给定ID控件的底边对齐

android:layout_alignBaseline----对齐到控件基准线

 

android:layout_above="@id/xxx"  --将控件置于给定ID控件之上
android:layout_below="@id/xxx"  --将控件置于给定ID控件之下

android:layout_toLeftOf="@id/xxx"  --将控件的右边缘和给定ID控件的左边缘对齐
android:layout_toRightOf="@id/xxx"  --将控件的左边缘和给定ID控件的右边缘对齐

android:layout_alignLeft="@id/xxx"  --将控件的左边缘和给定ID控件的左边缘对齐
android:layout_alignTop="@id/xxx"  --将控件的上边缘和给定ID控件的上边缘对齐
android:layout_alignRight="@id/xxx"  --将控件的右边缘和给定ID控件的右边缘对齐
android:layout_alignBottom="@id/xxx"  --将控件的底边缘和给定ID控件的底边缘对齐
android:layout_alignParentLeft="true"  --将控件的左边缘和父控件的左边缘对齐
android:layout_alignParentTop="true"  --将控件的上边缘和父控件的上边缘对齐
android:layout_alignParentRight="true"  --将控件的右边缘和父控件的右边缘对齐
android:layout_alignParentBottom="true" --将控件的底边缘和父控件的底边缘对齐
android:layout_centerInParent="true"  --将控件置于父控件的中心位置
android:layout_centerHorizontal="true"  --将控件置于水平方向的中心位置
android:layout_centerVertical="true"  --将控件置于垂直方向的中心位置

 

相对父容器,值是true或false
android:layout_alignParentLeft ------相对于父靠左
android:layout_alignParentTop-------相对于父靠上
android:layout_alignParentRight------相对于父靠右
android:layout_alignParentBottom ---相对于父靠下

android:layout_centerInParent="true" -------相对于父即垂直又水平居中
android:layout_centerHorizontal="true" -----相对于父即水平居中
android:layout_centerVertical="true" --------相对于父即处置居中

相对于父容器位置:

android:layout_margin="10dp"
android:layout_marginLeft
android:layout_marginRight
android:layout_marginTop
android:layout_marginBottom

版本4.2以上相对布局新属性

android:layout_alignStart---------------------将控件对齐给定ID控件的头部
android:layout_alignEnd----------------------将控件对齐给定ID控件的尾部
android:layout_alignParentStart--------------将控件对齐到父控件的头部
android:layout_alignParentEnd---------------将控件对齐到父控件的尾部

 

android:layout_marginLeft指该控件距离边父控件的边距,

android:paddingLeft指该控件内部内容,如文本距离该控件的边距。

 

来源:

http://blog.csdn.net/loongembedded/article/details/35569043

http://www.cnblogs.com/tinyphp/p/3787994.html

http://blog.csdn.net/softkexin/article/details/5933589/

http://www.cnblogs.com/yihujiu/p/5722088.html

更多相关文章

  1. Android子控件超出父控件方法
  2. Android 控件 ListView
  3. TextView(标签控件)
  4. Android的EditText控件常用属性
  5. Android的控件属性
  6. Android 让一个控件或布局居于底部的办法

随机推荐

  1. ninepatch 分析
  2. Zygote
  3. Android Gradle和Gradle插件区别
  4. Android使用cocos2d做简单的平移动画
  5. Android train——ListView绑定ArrayAdap
  6. 在Android(安卓)Studio下执行高德搜索你
  7. 杀掉指定进程
  8. Android判断包名和类名是否存在的方法
  9. 一网打尽Android UI 控件教程
  10. Linux-Ubuntu 18.04 LTS 安装 Oracle Vir