Android_RelativeLayout(相对布局)
2011-11-03 11:47
375 查看
布局属性 (以下是不据属性"注意 不是控件属性")如下:
int
ABOVE: 将 该控件 的 底部 放置于只定 ID 之上
android:layout_above="@id/xxx"
int
BELOW:将 该控件 的 顶部 放置于只定 ID 之下
android:layout_below="@id/xxx"
int
LEFT_OF:将 该控件 的 右边缘 放置于只定 ID 的左边对齐
android:layout_toLeftOf="@id/xxx"
int
RIGHT_OF:将 该控件 的 左边缘 放置于只定 ID 的右边对齐
android:layout_toRightOf="@id/xxx"
int ALIGN_LEFT:将 该控件 的 左边缘 放置于只定 ID 的左边对齐
int
ALIGN_RIGHT:将 该控件 的 右边缘 放置于只定 ID 的右边对齐
int
ALIGN_TOP:将 该控件 的 上边缘 放置于只定 ID 的上边对齐
int
ALIGN_BOTTOM:将 该控件 的 底边缘 放置于只定 ID 的底边对齐
int
ALIGN_BASELINE:
int
ALIGN_PARENT_BOTTOM:如果值为true 将 该控件 的 底边缘 放置于 父控件的底边缘 默认值为“false”
int
ALIGN_PARENT_LEFT:如果值为true 将 该控件 的 左边缘 放置于 父控件的左边缘 默认值为“false”
int
ALIGN_PARENT_RIGHT:如果值为true 将 该控件 的 右边缘 放置于 父控件的右边缘 默认值为“false”
int
ALIGN_PARENT_TOP: 如果值为true 将 该控件 的 顶边缘 放置于 父控件的顶边缘 默认值为“false”
int
CENTER_HORIZONTAL:如果值为true 水平居中
int
CENTER_IN_PARENT: 如果值为true 水平垂直都是居中
int
CENTER_VERTICAL: 如果值为true 垂直居中
TRUE
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10px"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/NOHAO"
android:text="NOHAO"
/>
<EditText
android:id="@+id/exitText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/NOHAO"
/>
<Button
android:id="@+id/OK"
android:text="确定"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/exitText"
/>
<Button
android:id="@+id/EXIT"
android:text="取消"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/OK"
android:layout_toLeftOf="@id/OK"
/>
</RelativeLayout>
int
ABOVE: 将 该控件 的 底部 放置于只定 ID 之上
android:layout_above="@id/xxx"
int
BELOW:将 该控件 的 顶部 放置于只定 ID 之下
android:layout_below="@id/xxx"
int
LEFT_OF:将 该控件 的 右边缘 放置于只定 ID 的左边对齐
android:layout_toLeftOf="@id/xxx"
int
RIGHT_OF:将 该控件 的 左边缘 放置于只定 ID 的右边对齐
android:layout_toRightOf="@id/xxx"
int ALIGN_LEFT:将 该控件 的 左边缘 放置于只定 ID 的左边对齐
int
ALIGN_RIGHT:将 该控件 的 右边缘 放置于只定 ID 的右边对齐
int
ALIGN_TOP:将 该控件 的 上边缘 放置于只定 ID 的上边对齐
int
ALIGN_BOTTOM:将 该控件 的 底边缘 放置于只定 ID 的底边对齐
int
ALIGN_BASELINE:
int
ALIGN_PARENT_BOTTOM:如果值为true 将 该控件 的 底边缘 放置于 父控件的底边缘 默认值为“false”
int
ALIGN_PARENT_LEFT:如果值为true 将 该控件 的 左边缘 放置于 父控件的左边缘 默认值为“false”
int
ALIGN_PARENT_RIGHT:如果值为true 将 该控件 的 右边缘 放置于 父控件的右边缘 默认值为“false”
int
ALIGN_PARENT_TOP: 如果值为true 将 该控件 的 顶边缘 放置于 父控件的顶边缘 默认值为“false”
int
CENTER_HORIZONTAL:如果值为true 水平居中
int
CENTER_IN_PARENT: 如果值为true 水平垂直都是居中
int
CENTER_VERTICAL: 如果值为true 垂直居中
TRUE
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10px"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/NOHAO"
android:text="NOHAO"
/>
<EditText
android:id="@+id/exitText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/NOHAO"
/>
<Button
android:id="@+id/OK"
android:text="确定"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/exitText"
/>
<Button
android:id="@+id/EXIT"
android:text="取消"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/OK"
android:layout_toLeftOf="@id/OK"
/>
</RelativeLayout>
相关文章推荐
- Android学习第二天之相对布局RelativeLayout
- Android布局之相对布局——RelativeLayout
- 【Android】7.5 RelativeLayout(相对布局)
- Android界面布局-----RelativeLayout(相对布局)
- android的五大布局(LinearLayout(线性布局)、FrameLayout(单帧布局)、RelativeLayout(相对布局)、AbsoluteLayout(绝对布局)和TableLa)
- .Net程序猿玩转Android开发---(7)相对布局RelativeLayout
- .Net程序员玩转Android开发---(7)相对布局RelativeLayout
- 浅谈android 的五大布局---LinearLayout(线性布局)、FrameLayout(单帧布局)、RelativeLayout(相对布局)、AbsoluteLayout(绝对布局)和Tab
- Android基础入门教程——2.2.2 RelativeLayout(相对布局)
- Android零基础入门第28节:轻松掌握RelativeLayout相对布局
- Android 相对布局 RelativeLayout常用属性
- Android组件----RelativeLayout相对布局的属性详解
- Android:控件布局(相对布局)RelativeLayout
- Android学习-RelativeLayout相对布局属性方法
- android布局------RelativeLayout(相对布局)详解
- Android基础入门教程——2.2.2 RelativeLayout(相对布局)
- android自学第三天 RelativeLayout相对布局和基本UI控件
- 【Android】RelativeLayout相对布局属性简析
- android 相对布局 RelativeLayout