zoukankan      html  css  js  c++  java
  • 7.Android开发笔记:布局控件(二)RelativeLayout 相对布局

    2.2 RelativeLayout

    RelativeLayout又称作相对布局,通过相对定位的方式让控件出现在布局的任何位置。也正因为如此,RelativeLayout中的属性非常多,不过这些属性都是有规律可循的。

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent" android:layout_height="match_parent">
       <!--相对于RelativeLayout布局-->
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="button左上"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"/>
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="button右上"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"/>
    
        <Button android:id="@+id/rl_btn_mid"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="button中"
            android:layout_centerInParent="true" />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="button左下"
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true"/>
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="button右下"
            android:layout_alignParentRight="true"
            android:layout_alignParentBottom="true"/>
    
    
        <!--相对于控件 【button中(ID:rl_btn_mid】-->
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="相对于【button中(ID:rl_btn_mid)】的左上"
            android:layout_toLeftOf="@+id/rl_btn_mid"
            android:layout_above="@+id/rl_btn_mid"
            />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="相对于【button中(ID:rl_btn_mid)】的右上"
            android:layout_toRightOf="@+id/rl_btn_mid"
            android:layout_above="@+id/rl_btn_mid"
            />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="相对于【button中(ID:rl_btn_mid)】的左下"
            android:layout_toLeftOf="@+id/rl_btn_mid"
            android:layout_below="@+id/rl_btn_mid"
            />
    
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAllCaps="false"
            android:text="相对于【button中(ID:rl_btn_mid)】的右下上"
            android:layout_toRightOf="@+id/rl_btn_mid"
            android:layout_below="@+id/rl_btn_mid"
            />
    
    </RelativeLayout>
    

  • 相关阅读:
    2012年的结束
    学习嵌入式的点滴(一)
    面试的点滴(一)
    学习嵌入式的点滴(二)
    DB2 SQL脚本批量执行(转)
    联邦数据库的一个例子(转)
    在 DB2 9.7 for Linux, UNIX, and Windows 上运行 Oracle 应用程序(转)
    WINDOWS批处理命令详解(转)
    SQL1159 Initialization error with DB2 .NET Data Provider, reason code 2;reason code 10
    Oracle Package中的包变量的使用(转)
  • 原文地址:https://www.cnblogs.com/easy5weikai/p/12459588.html
Copyright © 2011-2022 走看看