相对布局常用属性:

子类控件相对子类控件:值是另外一个控件的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

Android:控件布局(相对布局)RelativeLayout(转)的更多相关文章

  1. 探究android控件及布局

    控件(widget) 1. TextView(该控件的一些需要注意的属性,下同) gravity="center"textSize="24sp"textColo ...

  2. iOS 开发 ZFUI framework控件,使布局更简单

    来自:http://www.jianshu.com/p/bcf86b170d9c 前言 为什么会写这个?因为在iOS开发中,界面的布局一直没有Android布局有那么多的方法和优势,我个人开发都是纯代 ...

  3. Qt基本控件及三大布局

    Qt基本控件及三大布局 来源: http://blog.csdn.net/a2604539133/article/details/73920696 Qt基本模块 一.Qt的三大布局 QHBoxLayo ...

  4. c#学习笔记之使用 TableLayoutPanel 控件设置窗体布局

    使用 TableLayoutPanel 控件设置窗体布局 在 Visual Studio IDE 左侧,找到“工具箱”选项卡. 选择“工具箱”选项卡,随即将显示工具箱.(或者,在菜单栏上,依次选择“视 ...

  5. android控件的属性

    android控件的属性 本节描述android空间的位置,内容等相关属性及属性的含义 第一类:属性值为true或false android:layout_centerHrizontal 水平居中 ( ...

  6. 一步一步学android控件(之十五) —— DegitalClock & AnalogClock

    原本计划DigitalClock和AnalogClock单独各一篇来写,但是想想,两个控件的作用都一样,就和在一起写一篇了. DegitalClock和AnalogClock控件主要用于显示当前时间信 ...

  7. Android控件TextView的实现原理分析

    文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/8636153 在前面一个系列的文章中,我们以窗口 ...

  8. Android控件GridView之仿支付宝钱包首页带有分割线的GridView九宫格的完美实现

    Android控件GridView之仿支付宝钱包首页带有分割线的GridView九宫格的完美实现 2015-03-10 22:38 28419人阅读 评论(17) 收藏 举报  分类: Android ...

  9. Android控件介绍

    1. 介绍 Android控件大多位于android.widget, android.view.View为他们的父类对于Dialog系列, android.app.Dialog为父类 Android的 ...

  10. Android控件篇

    Android中提供了丰富的UI空间.为了最大限度地发挥平台的性能.每个开发人员必须熟练掌握UI控件尤其是经常使用的UI控件.并能依据须要呈现的内容选择最恰当的控件. Android提供了XML配置和 ...

随机推荐

  1. Mock制作假数据

    name 为属性名, rule 为规则, value 为值,属性名和生成规则之间用|分隔,生成规则的格式有7种: 字符串 String, 数字 Number, 布尔型 Boolean, 对象 Obje ...

  2. 基于html5整屏切换IDO智能手表页面滚动代码

    之前为大大家介绍了一款jquery实现的整屏切换特效.今天分享一款IDO智能手表页面滚动html5代码.这是一款基于jQuery+HTML5实现的页面滚动效果代码.效果图如下: 在线预览   源码下载 ...

  3. C++14尝鲜:Generic Lambdas(泛型lambda)

    所谓泛型lambda.就是在形參声明中使用auto类型指示说明符的lambda. 比方 auto lambda = [](auto x, auto y) {return x + y;}; 依据C++1 ...

  4. POj 1753--Flip Game(位运算+BFS)

    Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 30669   Accepted: 13345 Descr ...

  5. 核心交换机各项配置 Vlan划分、互访、ACL管控、链路聚合等

    #!Software Version V200R001C00SPC300sysname IT_ServerRoom  #交换机名称##vlan batch 10 20 30 40 50 60 70 8 ...

  6. hdu2896 病毒侵袭 AC自动机入门题 N(N <= 500)个长度不大于200的模式串(保证所有的模式串都不相同), M(M <= 1000)个长度不大于10000的待匹配串,问待匹配串中有哪几个模式串,

    /** 题目:hdu2896 病毒侵袭 链接:http://acm.hdu.edu.cn/showproblem.php?pid=2896 题意:N(N <= 500)个长度不大于200的模式串 ...

  7. expect模块的使用,主要没装包折腾一晚上

    第一步首先下载expect 模块,yum list |grep expect ,安装下面的模块. expect.x86_64                               5.44.1. ...

  8. iOS边练边学--自定义等高的cell

    一.storyboard自定义cell <1>创建一个继承自UITableViewCell的子类,比如ChaosDealCell <2>在storyboard中 <2.1 ...

  9. JS实现点击表头表格自动排序(含数字、字符串、日期)

    这篇文章主要介绍了利用JS如何实现点击表头后表格自动排序,其中包含数字排序.字符串排序以及日期格式的排序,文中给出了完整的示例代码,并做了注释,相信大家都能看懂,感兴趣的朋友们一起来看看吧. < ...

  10. MYSQL的用户变量(@)和系统变量(@@)

    9.3. 用户变量 可以先在用户变量中保存值然后在以后引用它:这样可以将值从一个语句传递到另一个语句.用户变量与连接有关.也就是说,一个客户端定义的变量不能被其它客户端看到或使用.当客户端退出时,该客 ...