Android布局---相对布局
Android布局分为五大类:相对布局、线性布局、表格布局、帧布局、网格布局
相对布局
语法格式:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmls:tools=""http://schemas.android.com/tools
android:layout_width=" "
android:layout_height=" ">
<Widgets>
android:id="@+id/ "
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal=" "
android:layout_alignParentLeft=" "
android:layout_marginLeft=" "
</Widgets>
</RelativeLayout>
相对父容器布局的语法属性
属性名称 属性说明
layout_alignParentLeft 以父容器的左边缘为参照标准
layout_marginLeft 控件左边缘距离父容器左边缘的距离
layout_alignParentRigth 以父容器的有边缘为参照标准
layout_marginRight 控件右边缘距离父容器右边缘的距离
layout_alignParentTop 以父容器的上边缘为参照标准
layout_marginTop 控件上边缘距离父容器上边缘的距离
layout_alignParentBottom 以父容器下边缘为参照标准
layout_marginBottom 控件下边缘距离父容器下边缘的距离
layout_centerHorizontal 控件在父容器中水平居中
layout_centerHorizontal 控件在父容器中垂直居中
layout_centerInParent 控件在父容器中央
例子:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"> <Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentTop="true"
android:layout_marginTop="128dp"
android:layout_centerHorizontal="true"
android:text="button1" /> </RelativeLayout>
相对控件布局的语法属性
属性名称 属性说明
layout_alignLeft 以已知控件的左边缘为参照标准
layout_marginLeft 控件的左边缘与已知控件之间的距离
layout_alignRight 以已知控件的右边缘为参照标准
layout_marginRight 控件的右边缘与已知控件之间的距离
layout_alignTop 以已知控件的上边缘为参考标准
layout_marginTop 控件的上边缘与已知控件之间的距离
layout_alignBottom 以已知控件的下边缘为参考标准
layout_marginBottom 控件的下边缘与已知控件之间的距离
layout_alignBaseLine 以已知控件的BaseLine为参考标准 layout_toRightOf 控件位于已知控件的右侧
layout_toLeftOf 控件位于已知控件的左侧
layout_above 控件位于已知控件的上侧
layout_below 控件位于已知控件的下侧 例子
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"> <Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_centerInParent="true"
android:text="button1"/> <Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignBottom="@+id/btn1"
android:layout_marginBottom="85dp"
android:layout_toRightOf="@+id/btn1"
android:text="button2"/> </RelativeLayout>
Android布局---相对布局的更多相关文章
- Android菜鸟成长记7 -- Android的五大布局
Android五大布局,相信android的都了解过,今天我根据自己的学习整理一下五大布局,主要介绍的是线性布局(LiearLayout),因为,其他的布局使用率不是很高. Android的五大布局 ...
- 无废话Android之常见adb指令、电话拨号器、点击事件的4种写法、短信发送器、Android 中各种布局(1)
1.Android是什么 手机设备的软件栈,包括一个完整的操作系统.中间件.关键的应用程序,底层是linux内核,安全管理.内存管理.进程管理.电源管理.硬件驱动 2.Dalvik VM 和 JVM ...
- Android first---常见布局
###绝对布局AbsoluteLayout * android:layout_x="120dp" 在水平方向上偏移120像素 * android:layout_y ...
- 14.Android之Layout布局学习
Android布局主要有5种,接下来学习总结下. 1) 最常见的线性布局 LinearLayout 线性布局是Android布局中最简单的布局,也是最常用,最实用的布局. android:orient ...
- Android中的布局优化方法
http://blog.csdn.net/rwecho/article/details/8951009 Android开发中的布局很重要吗?那是当然.一切的显示样式都是由这个布局决定的,你说能不重要吗 ...
- [置顶] Android系统五大布局详解Layout
我们知道Android系统应用程序一般是由多个Activity组成,而这些Activity以视图的形式展现在我们面前,视图都是由一个一个的组件构成的.组件就是我们常见的Button.TextEdit等 ...
- 个人经验 - Android的RelativeLayout布局的layout_height属性设置为wrap_content时的坑
Android的RelativeLayout布局的layout_height属性设置为wrap_content时的坑: 此坑出现的条件: 1.RelativeLayout布局的layout_heigh ...
- Android学习5—布局简介
Android界面的布局主要有四种,分别为RelativeLayout.LinearLayout.TableLayout.FrameLayout,接下来分别介绍这些布局如何使用(为了简单起见,接下来的 ...
- 【Android 复习】:Android五种布局的使用方法
---恢复内容开始--- 在Android布局中,有五种常用的布局,下面我们就来学习一下这几种布局的使用方式 1) 线性布局:LinearLayout 2) 帧布局: FrameLayout 3) ...
- Android学习----五大布局
1.LinearLayout 线性布局 android:orientation="horizontal" 制定线性布局的排列方式 水平 horizontal 垂直 vertical ...
随机推荐
- ScrollVIew 边界阴影效果
一.删除android ScrollView边界阴影方法方法 1) 在xml中添加:android:fadingEdge=”none” 2) 代码中添加:ScrollView.setHorizonta ...
- osx 10.11.5 El Capitan U盘制作安装
osx 10.11.5 El Capitan U盘制作安装 1. 下载osx10.11.5 从mac的 appstore下载(官方原版) 2. U盘8G起(注意备份重要资料) 3. 下载完成之后在Fi ...
- flasCC技术点记录
[待测试特性] 一.C接口导出相关 1.重载函数. 2.虚函数. 3.template相关 二.内存相关 1.as直接往c分配的内存写数据. 2.c直接往as对象写数据. 三.C访问AS 1.访问as ...
- backbone--部分总结
1.Backbone.history.start 方法可以让我们在点击后退或者前进的时候同样会触发路由的事件. 2.添加路由的路径,添加的路由路径要求重写父类的routes这个对象 var CustR ...
- HDU----(4291)A Short problem(快速矩阵幂)
A Short problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- hdu---(2604)Queuing(矩阵快速幂)
Queuing Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- 客户信贷管理&临时授信
信贷额度的组成:假如某客户信用限额1万:开出销售订单时锁定1万:一旦发货1万,销售订单1万限额释放,变成发货锁定限额1万.一旦开票,发货1万限额释放,应收锁定1万限额.清帐成功,应收释放1万.信用限额 ...
- ERP开发分享 1 数据库表设计
这是我的ERP设计经验分享系列,今天讲的是数据库的表设计(1),主要阐述: 1.单字段的主键:2.使用int32作为主键类型:3.使用版本字段处理乐观锁定:4.生效字段标明是否允许“被使用”:5.锁定 ...
- How to decide on the correct number of clusters?
Determining the number of clusters/segments in hierarchical clustering/segmentation algorithms 由于uni ...
- C语言知识整理(3):内存管理(详细版)
在计算机系统,特别是嵌入式系统中,内存资源是非常有限的.尤其对于移动端开发者来说,硬件资源的限制使得其在程序设计中首要考虑的问题就是如何有效地管理内存资源.本文是作者在学习C语言内存管理的过程中做的一 ...