您的位置:首页 > 移动开发 > Android开发

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>

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息