码迷,mamicode.com
首页 > 移动开发 > 详细

Android(java)学习笔记164:Relativelayout相对布局案例

时间:2015-08-16 12:08:57      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:

我们看看案例代码,自己心领神会:

<?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" >

    <Button
        android:id="@+id/bt_middle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="中间" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/bt_middle"
        android:layout_centerHorizontal="true"
        android:text="↑" />

    <Button
        android:id="@+id/bt_down"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/bt_middle"
        android:layout_centerHorizontal="true"
        android:text="↓" />

    <Button
        android:id="@+id/bt_left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@id/bt_middle"
        android:text="←" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@id/bt_middle"
        android:text="→" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/bt_left"
        android:layout_toLeftOf="@id/bt_down"
        android:text="↙" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button1"
        android:layout_alignBottom="@+id/button1"
        android:layout_toRightOf="@+id/button1"
        android:text="↗" />

</RelativeLayout>

布局效果图:

技术分享

Android(java)学习笔记164:Relativelayout相对布局案例

标签:

原文地址:http://www.cnblogs.com/hebao0514/p/4733772.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!