经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 移动开发 » Android » 查看文章
Android 相对布局 RelativeLayout
来源:cnblogs  作者:thomas_blog  时间:2019/11/4 8:29:24  对本文有异议
<!-- 在main元素的上方 -->
android:layout_above="@+id/main"
<!-- 在main元素的下方 -->
android:layout_below="@+id/main"
<!-- 在main元素的左边 -->
android:layout_toLeftOf="@+id/main"
<!-- 在main元素的右边 -->
android:layout_toRightOf="@+id/main"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="button" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button"
        android:layout_toLeftOf="@+id/button"
        android:text="button1" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button"
        android:layout_toRightOf="@+id/button"
        android:text="button2" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/button"
        android:layout_toLeftOf="@+id/button"
        android:text="button3" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/button"
        android:layout_toRightOf="@+id/button"
        android:text="button4" />

</RelativeLayout>
image

原文链接:http://www.cnblogs.com/zhangxuechao/p/11779184.html

 友情链接:直通硅谷  点职佳  北美留学生论坛