RelativeLayout里面各个控件对齐问题

举例

xml文件如下所示

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/bg_login"
    android:gravity="center"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/log_box"
        android:gravity="center"
        android:orientation="vertical" >

        <RelativeLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/et_login_pwd"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/et_login_name"
                android:layout_marginBottom="12dp"
                android:layout_marginLeft="110dp"
                android:background="@drawable/shuru"
                android:ems="10"
                android:password="true" >

                <requestFocus />
            </EditText>

            <TextView
                android:id="@+id/tv_login_forget_pwd"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/et_login_pwd"
                android:layout_marginLeft="120dp"
                android:text="@string/str_forget_pwd"
                android:textColor="@color/branse"
                android:textStyle="bold"
                android:textSize="20dp" />

            <Button
                android:id="@+id/btn_login_regist"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="56dp"
                android:layout_marginTop="75dp"
                android:layout_toRightOf="@+id/btn_login_login"
                android:background="@drawable/xml_regist_btn" />

            <Button
                android:id="@+id/btn_login_login"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_marginLeft="10dp"
                android:layout_toRightOf="@+id/et_login_pwd"
                android:background="@drawable/xml_login_btn" />

            <EditText
                android:id="@+id/et_login_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/et_login_pwd"
                android:layout_alignParentTop="true"
                android:layout_alignRight="@+id/et_login_pwd"
                android:layout_marginBottom="20dp"
                android:background="@drawable/shuru"
                android:ems="10" />

        </RelativeLayout>
    </LinearLayout>

</LinearLayout>

下图是按照UI设计出来的效果图

对于RelativeLayout 控件不熟悉

曾经参考

数据类型

常量名称

描述

int

ABOVE

定义将元素的底边对齐另一个元素的顶边

int

ALIGN_BASELINE

定义将元素基线的对齐另一个元素的基线

int

ALIGN_BOTTOM

定义将元素底边的对齐另一个元素的底边

int

ALIGN_LEFT

定义将元素的左边对齐另一个元素的左边

int

ALIGN_PARENT_BOTTOM

定义将元素的底边对齐其父容器(RelativeLayout)的底边

int

ALIGN_PARENT_LEFT

定义将元素的左边对齐其父容器(RelativeLayout)的左边

int

ALIGN_PARENT_RIGHT

定义将元素的右边对齐其父容器(RelativeLayout)的右边

int

ALIGN_PARENT_TOP

定义将元素的顶边对齐其父容器(RelativeLayout)的顶边

int

ALIGN_RIGHT

定义将元素的右边对齐另一个元素的右边

int

ALIGN_TOP

定义将元素的顶边对齐另一个元素的顶边

int

BELOW

定义将元素的顶边对齐另一个元素的底边

int

CENTER_HORIZONTAL

定义让元素在容器(RelativeLayout)内水平居中

int

CENTER_IN_PARENT

定义让元素位于容器(RelativeLayout)的中心

int

CENTER_VERTICAL

定义让元素在容器(RelativeLayout)内垂直居中

int

LEFT_OF

定义将元素的右边对齐另一个元素的左边

int

RIGHT_OF

定义将元素的左边对齐另一个元素的右边

int

TRUE

http://www.cnblogs.com/over140/archive/2011/01/26/1945083.html

 

  • 8
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值