Relativelayout(相对布局)示例
2015-05-15 21:41
190 查看
相对布局(RelativeLayout)
在这个容器内部的字子元素们可以使用彼此之间的相对位置,或容器之间的相对位置来进行定位。
相关属性:android:layout_abowe 将该控件置于给定ID的控件之上;
android:layout_below 将该控件置于给定ID的控件之下;
android:layout_toLeftOf 将该控件置于给定ID的控件之左;
android:layout_toRightOf 将该控件置于给定ID的控件之右;
android:layout_alignBaseline 该控件基线对齐给定ID的控件的基线;
android:layout_alignbBottom 该控件与给定ID的控件底部对齐;
android:layout_alignLeft 该控件与给定ID的控件左对齐;
android:layout_alignRight 该控件与给定ID的控件右对齐;
android:layout_alignTop 该控件与给定ID的控件顶对齐;
android:layout_alignParentLeft 如果为true,该控件位于父控件的左部;
android:layout_alignParentRight 如果为true,该控件位于父控件的右部;
android:layout_alignParentTop 如果为true,该控件位于父控件的顶部;
android:layout_alignParentBottom 如果为true,该控件位于父控件的低部;
android:layout_centerHorizontal 如果为true,该控件将被置于水平方向的中央;
android:layout_centerInParent 如果为true,该控件将被置于父控件水平方向和垂直方向;
android:layout_centerVertical 如果为true,该控件将被置于垂直方向的中央;
在这个容器内部的字子元素们可以使用彼此之间的相对位置,或容器之间的相对位置来进行定位。
相关属性:android:layout_abowe 将该控件置于给定ID的控件之上;
android:layout_below 将该控件置于给定ID的控件之下;
android:layout_toLeftOf 将该控件置于给定ID的控件之左;
android:layout_toRightOf 将该控件置于给定ID的控件之右;
android:layout_alignBaseline 该控件基线对齐给定ID的控件的基线;
android:layout_alignbBottom 该控件与给定ID的控件底部对齐;
android:layout_alignLeft 该控件与给定ID的控件左对齐;
android:layout_alignRight 该控件与给定ID的控件右对齐;
android:layout_alignTop 该控件与给定ID的控件顶对齐;
android:layout_alignParentLeft 如果为true,该控件位于父控件的左部;
android:layout_alignParentRight 如果为true,该控件位于父控件的右部;
android:layout_alignParentTop 如果为true,该控件位于父控件的顶部;
android:layout_alignParentBottom 如果为true,该控件位于父控件的低部;
android:layout_centerHorizontal 如果为true,该控件将被置于水平方向的中央;
android:layout_centerInParent 如果为true,该控件将被置于父控件水平方向和垂直方向;
android:layout_centerVertical 如果为true,该控件将被置于垂直方向的中央;
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="用户名" /> <Edittext android:id="@+id/edittext1" android:layout_height="wrap_content" android:layout_width="fill_parent" android:layout_below="@+id/textView1" /> <Button android:id="@+id/button1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_below="@id/edittext1" android:layout_alignParentRight="true" android:text="取消" android:layout_marginLeft="10dip" /> <Button android:id="@+id/button2" android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_toLeftOf="@id/button1" android:layout_alignBottom="@+id/button1" android:text="确定" android:layout_marginLeft="10dip" /> </RelativeLayout>
相关文章推荐
- Android之RelativeLayout相对布局
- Android中关于相对布局RelativeLayout的技巧汇总
- RelativeLayout相对布局
- 组合组件のCusRelativeLayout(Android-自定义相对布局)
- android之RelativeLayout(相对布局)
- 相对布局RelativeLayout
- 【android学习笔记】关于相对布局RelativeLayout的各种属性介绍
- RelativeLayout相对布局 安卓布局技巧
- android相对布局RelativeLayout的属性
- android中的相对布局RelativeLayout
- android五大布局之RelativeLayout(相对布局)
- Android五大布局方式——相对布局(RelativeLayout)属性详解
- 「喵神成长史」『布局篇』RelativeLayout(相对布局)
- Android 1.5和Android 2.1在相对布局(RelativeLayout)上的区别
- Android---->RelativeLayout相对对齐方式布局
- 基本布局之相对布局(RelativeLayout)
- Android相对布局RelativeLayout各属性介绍
- RelativeLayout 相对布局
- android 动态调整RelativeLayout布局控件的相对位置 layout_toLeftOf 之类的
- 相对布局(RelativeLayout)的简单使用