// 相对于给定ID控件
android:layout_above 将该控件的底部置于给定ID的控件之上;
android:layout_below 将该控件的底部置于给定ID的控件之下;
android:layout_toLeftOf 将该控件的右边缘与给定ID的控件左边缘对齐;
android:layout_toRightOf 将该控件的左边缘与给定ID的控件右边缘对齐; android:layout_alignBaseline 将该控件的baseline与给定ID的baseline对齐;
android:layout_alignTop 将该控件的顶部边缘与给定ID的顶部边缘对齐;
android:layout_alignBottom 将该控件的底部边缘与给定ID的底部边缘对齐;
android:layout_alignLeft 将该控件的左边缘与给定ID的左边缘对齐;
android:layout_alignRight 将该控件的右边缘与给定ID的右边缘对齐;
// 相对于父组件
android:layout_alignParentTop 如果为true,将该控件的顶部与其父控件的顶部对齐;
android:layout_alignParentBottom 如果为true,将该控件的底部与其父控件的底部对齐;
android:layout_alignParentLeft 如果为true,将该控件的左部与其父控件的左部对齐;
android:layout_alignParentRight 如果为true,将该控件的右部与其父控件的右部对齐;
// 居中
android:layout_centerHorizontal 如果为true,将该控件的置于水平居中;
android:layout_centerVertical 如果为true,将该控件的置于垂直居中;
android:layout_centerInParent 如果为true,将该控件的置于父控件的中央;
// 指定移动像素
android:layout_marginTop 上偏移的值;
android:layout_marginBottom 下偏移的值;
android:layout_marginLeft   左偏移的值;
android:layout_marginRight   右偏移的值; example:
android:layout_below = "@id/***"
android:layout_alignBaseline = "@id/***"
android:layout_alignParentTop = true
android:layout_marginLeft = “10px <?xmlversion="1.0"encoding="utf-8"?>
<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"android:layout_height="fill_parent"
android:orientation="vertical"> <RelativeLayoutandroid:id="@+id/Relativelayout01"
android:layout_width="wrap_content"android:layout_height="wrap_content">
<!-- 第一个设置的默认居于父容器的左上部 -->
<Buttonandroid:id="@+id/a"android:text="AAAA"
android:layout_width="wrap_content"android:layout_height="wrap_content">
</Button>
<!-- 设置b位于a的右边 -->
<Buttonandroid:id="@+id/b"android:text="BBBB"
android:layout_width="wrap_content"android:layout_height="wrap_content"
android:layout_toRightOf="@+id/a"></Button>
<!-- 设置c位于a的下面,默认居父容器的左部 -->
<Buttonandroid:id="@+id/c"android:text="CCCC"
android:layout_width="wrap_content"android:layout_height="wrap_content"
android:layout_below="@+id/a"></Button>
<!--
设置d位于c的右边,b的下面,如果没有设置居于c的右边,则偏离左边的位置就是其中的margin值,是如果没有设置layout_below
则放置在跟b的位置同一水平位置居于c的右边,设置左、上距离是20dp
-->
<Buttonandroid:id="@+id/d"android:text="DDDD"
android:layout_width="wrap_content"android:layout_height="wrap_content"
android:layout_toRightOf="@+id/c"android:layout_below="@+id/b"
android:layout_marginTop="20dp"android:layout_marginLeft="20dp"></Button>
</RelativeLayout> </LinearLayout> 效果如下:

android RelativeLayout属性和布局实例的更多相关文章

  1. Android RelativeLayout 实现左右中布局

    效果图如下: 代码如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns ...

  2. Android RelativeLayout属性含义

    a).第一类:属性值为true或false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 android ...

  3. Android RelativeLayout 属性

    // 相对于给定ID控件 android:layout_above 将该控件的底部置于给定ID的控件之上; android:layout_below 将该控件的底部置于给定ID的控件之下; andro ...

  4. Android RelativeLayout 属性 转自互联网

    // 相对于给定ID控件 android:layout_above 将该控件的底部置于给定ID的控件之上; android:layout_below 将该控件的底部置于给定ID的控件之下; andro ...

  5. [Android] RelativeLayout, LinearLayout,FrameLayout

    Android RelativeLayout 属性 // 相对于给定ID控件 android:layout_above 将该控件的底部置于给定ID的控件之上; android:layout_below ...

  6. Android:布局实例之模仿京东登录界面

    预览图及布局结构参考: 布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout ...

  7. Android四种基本布局(LinearLayout \ RelativeLayout \ FrameLayout \ TableLayout)

    ------------------------------------------LinearLayout---------------------------------------------- ...

  8. Android:控件布局(相对布局)RelativeLayout

    RelativeLayout是相对布局控件:以控件之间相对位置或相对父容器位置进行排列. 相对布局常用属性: 子类控件相对子类控件:值是另外一个控件的id android:layout_above-- ...

  9. 【Android布局】在程序中设置android:gravity 和 android:layout_Gravity属性

    在进行UI布局的时候,可能常常会用到 android:gravity  和 android:layout_Gravity 这两个属性. 关于这两个属性的差别,网上已经有许多人进行了说明,这边再简单说一 ...

随机推荐

  1. Mysql 比较运算符详解

    熟悉了最简单的算术运算符,再来看一下比较运算符.当使用SELECT 语句进行查询时,MySQL允许用户对表达式的左边操作数和右边操作数进行比较,比较结果为真,则返回1,为假则返回0,比较结果不确定则返 ...

  2. 使用zlib模块实现HTTP服务端与客户端实现传输数据压缩

    现如今在处理http请求的时候,由于请求的资源较多,如果不启用压缩的话,那么页面请求的流量将会非常大.启用gzip压缩,在一定程度上会大大的提高页面性能. 因此这写一个使用Node.js实现在http ...

  3. CentOS中安装JDK与Intellij idea

    卸载CentOS中自带openjdk CentOS自带openjdk,可以先用java –version检测是否存在jdk版本.如果存在,最好在安装oracle的jdk之前最好卸载,可以使用如下指令 ...

  4. ajax处理select下拉表单

    $('#gameid').change(function() { var gameid = $(this).val(); if (this.value != '') { $.ajax({ url: ' ...

  5. CSS3 图片旋转

    .nav_all { position:relative; z-index:; width:172px; display:inline; ; } .nav_all b { display:block; ...

  6. 根据返回值动态加载select

    // 路由 if (return_routeChoice != null && return_routeChoice != "") { for (var i = 0 ...

  7. windows测试模式

    测试模式通常意义就是让windows 操作系统在测试状态下运行,windows操作系统在这种模式下可以运行非官方或无数字签名的驱动程序 .   目录 1 定义 2 进入/退出windows测试模式方法 ...

  8. cocos2dx场景切换的坑

    有一个类可以使用不同的数据源,每个数据源对应一个对象. 我在类里保存了对象的实例,由于要在其它地方使用所以做成了静态,并在每次初始化时 重新设置,析构时删除. 现在我打开了A,切换到B,结果这个静态的 ...

  9. lua工具库penlight--03字符串

    字符串提取函数 这些方法也是从Python借鉴来的,但索引从1开始.stringx定义了一些函数如isalpha和isdigit, 用来判断字母和数字:startswith和endswith可以方便用 ...

  10. boa 服务的启动

    使用 buildroot 添加 boa 服务后,通过命令 boa 不能启动该服务,就研究了一下boa.conf的配置. etc/boa/boa.conf # 更改user 和Group 为root. ...