Android笔记:RelativeLayout
RelativeLayout 又称作相对布局,也是一种非常常用的布局。和 LinearLayout 的排列规
则不同,RelativeLayout 显得更加随意一些,它可以通过相对定位的方式让控件出现在布局
的任何位置。
注意:RelativeLayout不支持权重的设置,android:layout_weight仅能在LinearLayout中使用
控件之间的关系:
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" --将控件置于垂直方向的中心位置
控件的边距:
注:一个控件跟另一个控件的距离叫边距(margin)
android:layout_marginBottom="30dp" 下边距为30dp
android:layout_marginLeft="30dp" 左边距为30dp
android:layout_marginRight="30dp" 右边距为30dp
android:layout_marginTop="30dp" 上边距为30dp
Android笔记:RelativeLayout的更多相关文章
- Android笔记——Android中数据的存储方式(二)
我们在实际开发中,有的时候需要储存或者备份比较复杂的数据.这些数据的特点是,内容多.结构大,比如短信备份等.我们知道SharedPreferences和Files(文本文件)储存这种数据会非常的没有效 ...
- 关于java.lang.NoSuchMethodError: android.widget.RelativeLayout.setBackground的解决办法
今天用一个安卓4.0.4版本的手机测试手上的项目,发现logcat弹出这样一个提示“java.lang.NoSuchMethodError: android.widget.RelativeLayout ...
- java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView
最近在学习drawerLayout时,遇到这个bug.如下示: java.lang.ClassCastException: android.widget.RelativeLayout cannot b ...
- 个人经验 - Android的RelativeLayout布局的layout_height属性设置为wrap_content时的坑
Android的RelativeLayout布局的layout_height属性设置为wrap_content时的坑: 此坑出现的条件: 1.RelativeLayout布局的layout_heigh ...
- 加载程序到android虚拟机报错: android.widget.RelativeLayout cannot be cast to android.widget.Button
05-23 02:53:48.416: E/Trace(875): error opening trace file: No such file or directory (2) 05-23 02:5 ...
- Android笔记:触摸事件的分析与总结----TouchEvent处理机制
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://glblong.blog.51cto.com/3058613/1559320 ...
- 从零開始学android<RelativeLayout相对布局.十六.>
相对布局管理器指的是參考某一其它控件进行摆放,能够通过控制,将组件摆放在一个指定參考组件的上.下.左.右等位置,这些能够直接通过各个组件提供的属性完毕. 以下介绍一下各个方法的基本使用 No. 属性名 ...
- [Android笔记1]Activity+Layout+Button
线性布局(LinearLayout)是指view对象在父view中可按水平或垂直方向线性排列. 相对布局(RelativeLayout)是指view对象的排列依赖于各对象之间的相对位置. 下面是展示两 ...
- java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.w ...
- android笔记---LoginActivity extends FinalActivity
package com.fuda.activity; import java.io.BufferedReader; import java.io.File; import java.io.FileNo ...
随机推荐
- 【Spring实战-3】Spring整合Hibernate、Struts
作者:ssslinppp 1. 摘要 版本: Spring4.0.4:Hibernate4.3.5:struts2.3.16: 主要介绍了如下内容: 项目结构的规划: Spring下整合Hi ...
- bzoj 2601: [Jsoi2011]同分异构体计数
Description Antonio 最近对有机化学比较感兴趣,他想请你帮助他快速计算出某种烃类的同分异 构体的数目. 为了表述方便,我们作出如下定义: 环烷烃: 具有n 个碳原子的环烷烃可 ...
- requests-1快速学习
请直接转身官网http://docs.python-requests.org/zh_CN/latest/user/quickstart.html#url](http://docs.python-req ...
- 挂载本地ISO
http://www.linuxidc.com/Linux/2017-03/142087.htm 挂载本地ISO mount -o loop /home/iso/RHEL-server-7.0-x86 ...
- [UE4]创建对象的的几种姿势(C++)
DEMO源代码 这个DEMO演示了在C++代码中,创建UE4的常见类型的对象,包括Actor,ActorComponent,加载资源等. 源代码请从这里下载:https://code.csdn.net ...
- Linux系统文件名字体不同的颜色都代表什么
Linux系统文件名字体不同的颜色都代表什么 在Linux中,文件的颜色都是有含义的. 其中, Linux中文件名颜色不同,代表文件类型不一样. 如下所示: www.2cto.com ...
- Linux命令详解-ftp服务器配置
1.ftp服务器配置 1.ftp安装: rpm –qa | grep ftp 2.查看安装内容: rpm-ql |more 3.启动ftp服务: service vsftpd start 4.配置文件 ...
- OpenGL chapter2
opengl: 图形硬件的一种软件接口:最大的优点:它的速度快于光线追踪器或软件渲染引擎. GLUT: AUX是OpenGL辅助函数库. 数据类型: GLboolean 位宽:1 GLbyte 8 G ...
- python logging模块使用教程
简单使用 #!/usr/local/bin/python # -*- coding:utf-8 -*- import logging logging.debug('debug message') lo ...
- linux主机555、644、666、755、777权限详解
linux主机555.644.666.755.777权限详解 发表时间:2014-06-03 05:07 来源:未知 分类:其它代码 作者:岑溪网站开发 点击:次 linux主机555.644.666 ...