Android 相对布局

用Android相对布局设计一个Android界面,并能够在Android模拟器上成功运行。

1.相关代码:

<!-- 这个是在应用中间 -->
<ImageView
    android:id="@+id/img"
    android:layout_width="@dimen/diment"
    android:layout_height="@dimen/diment"
    android:layout_centerInParent="true"
    android:src="@drawable/img"/>

<!-- 在中间图片的左上角 -->
<ImageView
    android:id="@+id/img1"
    android:layout_width="@dimen/diment"
    android:layout_height="@dimen/diment"
    android:layout_toLeftOf="@id/img"
    android:layout_above="@id/img"
    android:src="@drawable/img1"/>

<!-- 在中间图片的正上方-->
<ImageView
    android:id="@+id/img2"
    android:layout_width="@dimen/diment"
    android:layout_height="@dimen/diment"
    android:layout_above="@id/img"
    android:layout_centerHorizontal="true"
    android:src="@drawable/img2"/>

<!-- 在中间图片的右上角 -->
<ImageView
    android:id="@+id/img3"
    android:layout_width="@dimen/diment"
    android:layout_height="@dimen/diment"
    android:layout_toRightOf="@id/img"
    android:layout_above="@id/img"
    android:layout_centerVertical="true"
    android:src="@drawable/img3"/>

<!-- 在中间图片的左边 -->
<ImageView
    android:id="@+id/img4"
    android:layout_width="@dimen/diment"
    android:layout_height="@dimen/diment"
    android:layout_toLeftOf="@id/img"
    android:layout_centerVertical="true"
    android:src="@drawable/img4"/>

<!-- 在中间图片的右边 -->
<ImageView
    android:id="@+id/img5"
    android:layout_width="@dimen/diment"
    android:layout_height="@dimen/diment"
    android:layout_toRightOf="@id/img"
    android:layout_centerVertical="true"
    android:src="@drawable/img5"/>

<!-- 在中间图片的左下角 -->
<ImageView
    android:id="@+id/img6"
    android:layout_width="@dimen/diment"
    android:layout_height="@dimen/diment"
    android:layout_toLeftOf="@id/img"
    android:layout_below="@id/img"
    android:layout_centerHorizontal="true"
    android:src="@drawable/img6"/>

<!-- 在中间图片的下面 -->
<ImageView
    android:id="@+id/img7"
    android:layout_width="@dimen/diment"
    android:layout_height="@dimen/diment"
    android:layout_below="@id/img"
    android:layout_centerHorizontal="true"
    android:src="@drawable/img7"/>

<!-- 在中间图片的右下方 -->
<ImageView
    android:id="@+id/img8"
    android:layout_width="@dimen/diment"
    android:layout_height="@dimen/diment"
    android:layout_toRightOf="@id/img"
    android:layout_below="@id/img"
    android:layout_centerHorizontal="true"
    android:src="@drawable/img8"/>

2.效果图:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值