layout layout_alignLeft跟layout_toLeftOf
今天调布局的时候 想把界面做成横屏竖屏都可以的 突然发现之前理解的android:布局参数都是有问题的 今天贴出来 下次自己也记得
以下大部为用在RelativeLayout中的一些参数:
android:layout_above 将该控件的底部至于给定ID的控件之上,但不会左对齐,默认置于父窗口最左边,会覆盖最左边的控件
android:layout_below 将该控件的顶部至于给定ID的控件之下,但不会左对齐,默认置于父窗口最左边,会覆盖最左边的控件
android:layout_toLeftOf 将该控件的右边缘和给定ID的控件的左边缘对齐,默认置于父窗口最上面,会覆盖最上面的控件
android:layout_toRightOf 将该控件的左边缘和给定ID的控件的右边缘对齐,默认置于父窗口最上面,会覆盖最上面的控件
android:alignParentBottom 如果该值为true,则将该控件的底部和父控件的底部对齐,默认置于父窗口最左下,会覆盖最左下的控件
android:layout_alignParentLeft 如果该值为true,则将该控件的左边与父控件的左边对齐,默认置于父窗口最左上,会覆盖最左上的控件
android:layout_alignParentRight 如果该值为true,则将该控件的右边与父控件的右边对齐,默认置于父窗口最右上,会覆盖最右上的控件
android:layout_alignParentTop 如果该值为true,则将控件的顶部与父控件的顶部对齐,默认置于父窗口最左上,会覆盖最左上的控件
android:layout_alignBaseline该控件的baseline和给定ID的控件的baseline对齐,并置于父窗口最左边,会覆盖最左边的控件
android:layout_alignBottom 将该控件的底部边缘与给定ID控件的底部边缘对齐,并置于父窗口最左边,会覆盖最左边的控件
android:layout_alignLeft 将该控件的左边缘与给定ID控件的左边缘对齐,并置于父窗口最上边,会覆盖最上边的控件
android:layout_alignRight 将该控件的右边缘与给定ID控件的右边缘对齐,并置于父窗口最上边,会覆盖最上边的控件
android:layout_alignTop 将给定控件的顶部边缘与给定ID控件的顶部对齐,并置于父窗口最左边,会覆盖最左边的控件
原文:http://my.oschina.net/honeyming/blog/130761
实例1介绍: -- 未加入对齐方式
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.relativelayoutdemo.MainActivity" > <TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/hello_world" /> <TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv1"
android:text="@string/hello_world" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tv1"
android:text="@string/hello_world" /> </RelativeLayout>
效果:

实例2介绍: -- 加入对齐方式 。在tv1下面的对齐方式是左边界对齐。在tv1右边的对齐方式是上边界对齐。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.relativelayoutdemo.MainActivity" > <TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/hello_world" /> <TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv1"
android:layout_alignLeft="@id/tv1"
android:text="@string/hello_world" /> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/tv1"
android:layout_alignTop="@id/tv1"
android:text="@string/hello_world" /> </RelativeLayout>
结果:

layout layout_alignLeft跟layout_toLeftOf的更多相关文章
- android:layout_alignleft layout_toleftof区别,详解RelativeLayout布局属性
转载请注明博客地址. 最近看博客看到有关于RelativeLayout布局的解释,有的解释很多是错误的.因此有必要对每一个常见的布局属性进行描述.以下解释全部都是逐行进行测试的. 首先把常用的布局分组 ...
- 【Android UI】Android Layout XML属性
Layout对于迅速的搭建界面和提高界面在不同分辨率的屏幕上的适应性具有很大的作用.这里简要介绍Android的Layout和研究一下它的实现. Android有Layout:FrameLayout, ...
- Android Layout XML属性
转载自并做少量添加:http://www.cnblogs.com/playing/archive/2011/04/07/2008620.html Layout对于迅速的搭建界面和提高界面在不同分辨率的 ...
- 14.Android之Layout布局学习
Android布局主要有5种,接下来学习总结下. 1) 最常见的线性布局 LinearLayout 线性布局是Android布局中最简单的布局,也是最常用,最实用的布局. android:orient ...
- layout相关
大致看了看布局大致有5种(approximately) 1. LinearLayout 2. RelativeLayout 3. FrameLayout 4. TableLayout 5. GridL ...
- [置顶] Android系统五大布局详解Layout
我们知道Android系统应用程序一般是由多个Activity组成,而这些Activity以视图的形式展现在我们面前,视图都是由一个一个的组件构成的.组件就是我们常见的Button.TextEdit等 ...
- Android--应用开发3(Android layout XML属性)
Android layout XML属性 转载:http://www.cnblogs.com/playing/archive/2011/04/07/2008620.html Layout对于迅速的搭建 ...
- Android系统五大布局详解Layout
我们知道Android系统应用程序一般是由多个Activity组成,而这些Activity以视图的形式展现在我们面前, 视图都是由一个一个的组件构成的.组件就是我们常见的Button.TextEdit ...
- Layout基本属性总结
在Android中,共有五种布局方式,分别是:FrameLayout(框架布局),LinearLayout (线性布局),GridLayout(网格布局),RelativeLayout(相对布局),T ...
随机推荐
- c++ 2.1 编译器何时创建默认构造函数
我们通常会说当生命一个 class 时,如果我们不为该 class 指定一个 constructor,那么编译器会替我们实现一个 connstructor,那么这种说法一定对吗? 事实上,这是不对的. ...
- DOM对象转化成jQuery对象
相比较jQuery转化成DOM,开发中更多的情况是把一个DOM对象加工成jQuery对象.$(参数)是一个多功能的方法,通过传递不同的参数而产生不同的作用. 如果传递给$(DOM)函数的参数是一个DO ...
- DP石子合并问题
转自:http://www.hnyzsz.net/Article/ShowArticle.asp?ArticleID=735 [石子合并] 在一个圆形操场的四周摆放着n 堆石子.现要将石子有次序 ...
- H3C交换机端口链路聚合
H3C交换机端口链路聚合 以太网链路聚合 -- 以太网链路聚合配置命令 -- lacp system-prioritylacp system-priority命令用来配置系统的LACP优先级.undo ...
- [bzoj] 2453 维护数列 || 单点修改分块
原题 询问区间有种个颜色,单点修改某个位置. 修改次数<=1000 维护pre[i]为前一个与当前位置颜色一样的位置. 询问时以pre为关键字sort,lower_bound找pre<x的 ...
- 洛谷 最小费用最大流 模板 P3381
#include<cstdio> #include<algorithm> #include<cstring> #include<queue> #defi ...
- 性能优化-使用 RAIL 模型评估性能
RAIL 是一种以用户为中心的性能模型.每个网络应用均具有与其生命周期有关的四个不同方面,且这些方面以不同的方式影响着性能: TL;DR 以用户为中心:最终目标不是让您的网站在任何特定设备上都能运行很 ...
- python使用openpyxl操作excel
def initExcel(): file_path = "test.xlsx" file = load_workbook(file_path) table = file[&quo ...
- Nodejs 基础知识 浅析
1. 模块化 ①常用模块化规范 CommonJS + nodejs AMD(Asynchronous Module Definition) + RequireJS CMD(Common Module ...
- myeclipse maven web项目配置
启用maven:window-->preference-->MyEclipse-->Maven4MyEclipse, 勾选复选框(Enable Mave4MyEclipse feat ...