android 相对布局_【学习】安卓212相对布局的练习含代码版

2-1-2RelativeLayout相对布局

640?wx_fmt=png

相对布局关键就是“相对”是一个方位类型的定位,不是按照找单一的形式排序的。即a可以放在b后面,也可以放在前面,不定的。随机性高~基本上线性布局有的属性,它都有。

640?wx_fmt=png

640?wx_fmt=png

学习一些属性的应用。

预览的视图如下:

640?wx_fmt=png

640?wx_fmt=jpeg

真机运行的截图

下列为该次实验代码,依旧是在

640?wx_fmt=png

这个xml文件

代码:

<?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"    >    <View        android:id="@+id/view_1"        android:layout_width="100dp"        android:layout_height="100dp"        android:background="#100000" />    <View        android:layout_width="100dp"        android:layout_height="100dp"        android:background="#02f122"        android:id="@+id/view_2"        android:layout_toRightOf="@id/view_1"       />    <LinearLayout        android:id="@+id/line_1"        android:layout_width="match_parent"        android:layout_height="300dp"        android:background="#1564fd"        android:orientation="horizontal"        android:layout_below="@id/view_1"        android:padding="15dp"        >        <View            android:layout_width="100dp"            android:layout_height="match_parent"            android:background="#fad"            />        <View            android:layout_width="100dp"            android:layout_height="match_parent"            android:background="#adfd"            />        <RelativeLayout            android:layout_width="match_parent"            android:layout_height="match_parent"            android:background="@color/black"            android:padding="15dp"            >            <View                android:id="@+id/view_3"                android:layout_width="25dp"                android:layout_height="match_parent"                android:background="#ff1"                />            <View                android:layout_width="25dp"                android:layout_height="match_parent"                android:background="#02f122"                android:id="@+id/view_4"                android:layout_toRightOf="@id/view_3"                android:layout_marginLeft="100dp"                />        RelativeLayout>    LinearLayout>RelativeLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值