android的嵌套布局管理的案例

下面是运行效果图

添加在xml的代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="16dp"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="16dp"
    android:orientation="vertical"
    tools:context=".MainActivity"

   >

    <RelativeLayout
        android:layout_width="382dp"
        android:layout_height="168dp">


        <ImageView
            android:id="@+id/icol"
            android:layout_width="70dp"
            android:layout_height="59dp"
            android:layout_marginStart="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginEnd="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginBottom="10dp"
            android:src="@mipmap/xiaotu2" />
        <TextView
            android:id="@+id/name1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_toRightOf="@+id/icol"
            android:text="晓晓"
            android:textColor="#576B95" />
        <TextView
            android:id="@+id/content1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="祝我的亲人,朋友们新年快乐!"
            android:layout_marginTop="5dp"
            android:minLines="3"
            android:layout_marginBottom="5dp"
            android:layout_toRightOf="@+id/icol"
            android:layout_below="@+id/name1"

           />

        <TextView
            android:id="@+id/time1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/content1"
            android:layout_alignLeft="@+id/icol"
            android:layout_marginTop="12dp"
            android:text="昨天"
            android:textColor="#9A9A9A" />

        <ImageView
            android:layout_width="41dp"
            android:layout_height="33dp"
            android:layout_below="@id/content1"
            android:layout_alignParentRight="true"
            android:layout_marginTop="26dp"
            android:layout_marginRight="25dp"
            android:src="@mipmap/xx" />
    </RelativeLayout>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="8dp"
        android:background="@mipmap/xt" />
    <RelativeLayout
        android:layout_width="382dp"
        android:layout_height="168dp">


        <ImageView
            android:id="@+id/ico2"
            android:layout_width="70dp"
            android:layout_height="59dp"
            android:layout_marginStart="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginEnd="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginBottom="10dp"
            android:src="@mipmap/beiji" />
        <TextView
            android:id="@+id/name2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_toRightOf="@+id/ico2"
            android:text="开心"
            android:textColor="#576B95" />
        <TextView
            android:id="@+id/content2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="奋斗就是每一天都很难,可一年比一年容易。不奋斗就是每一天都很容易,可以一年比一年难!"
            android:layout_marginTop="5dp"
            android:minLines="3"
            android:layout_marginBottom="5dp"
            android:layout_toRightOf="@+id/ico2"
            android:layout_below="@+id/name2"

            />

        <TextView
            android:id="@+id/time2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/content2"
            android:layout_alignLeft="@+id/icol"
            android:layout_marginTop="14dp"
            android:text="六小时前"
            android:textColor="#9A9A9A"
            tools:ignore="NotSibling" />

        <ImageView
            android:layout_width="41dp"
            android:layout_height="33dp"
            android:layout_below="@id/content2"
            android:layout_alignParentRight="true"
            android:layout_marginTop="28dp"
            android:layout_marginRight="24dp"
            android:src="@mipmap/xx" />
    </RelativeLayout>

    <ImageView
        android:layout_width="393dp"
        android:layout_height="11dp"
        android:background="@mipmap/xt" />
</LinearLayout>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值