android的布局-----RelativeLayout(相对布局)

学习导图

注:父容器定位的属性值只能是Boolean ,兄弟组件定位的属性值只能是ID

 典型案例(梅花)

<?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">
    <ImageView
        android:id="@+id/img1"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_centerInParent="true"
        android:src="@mipmap/ic_launcher"/>
    <ImageView
        android:id="@+id/img2"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_above="@id/img1"
        android:layout_centerHorizontal="true"
        android:src="@mipmap/ic_launcher"/>
    <ImageView
        android:id="@+id/img3"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_below="@id/img1"
        android:layout_centerHorizontal="true"
        android:src="@mipmap/ic_launcher"/>
    <ImageView
        android:id="@+id/img4"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_toLeftOf="@id/img1"
        android:layout_centerVertical="true"
        android:src="@mipmap/ic_launcher"/>
    <ImageView
        android:id="@+id/img5"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_toRightOf="@id/img1"
        android:layout_centerVertical="true"
        android:src="@mipmap/ic_launcher"/>

</RelativeLayout>

 

posted @ 2015-12-30 19:54  会飞的一只狼  阅读(470)  评论(0编辑  收藏  举报