Android基本布局案例

一、案例效果
在这里插入图片描述
二、src/main/res/layout/active_main.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:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="#F8F9FA"
    tools:context="com.black.sq.lesson03.Main6Activity">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="#18B4ED">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:text="看点"
            android:layout_centerInParent="true"
            android:gravity="center"
            android:textColor="#fff"
            android:textSize="18sp" />
        <TextView
            android:layout_width="80dp"
            android:gravity="center"
            android:layout_alignParentRight="true"
            android:layout_height="match_parent"
            android:text="更多"
            android:textSize="12sp"
            android:textColor="#fff"/>
    </RelativeLayout>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_height="30dp">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <EditText
                android:id="@+id/et"
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:cursorVisible="false"
                android:paddingLeft="10dp"
                android:textSize="16sp"
                android:textColor="#ddd"
                />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/ll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:layout_gravity="center">
            <ImageView
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:src="@drawable/green"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20sp"
                android:text="私信"
                android:textColor="#ddd"
                android:gravity="center_horizontal"/>
        </LinearLayout>
    </RelativeLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:background="#fff"
        android:orientation="horizontal">
        <LinearLayout
            android:layout_width="0dp"
            android:layout_weight="1"
            android:orientation="vertical"
            android:layout_height="match_parent">
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginTop="8dp"
                android:src="@drawable/you"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="你"
                android:gravity="center_horizontal"
                android:layout_marginTop="8dp"
                android:textColor="#444"/>
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_weight="1"
            android:orientation="vertical"
            android:layout_height="match_parent">
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginTop="8dp"
                android:src="@drawable/good"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="好"
                android:gravity="center_horizontal"
                android:layout_marginTop="8dp"
                android:textColor="#444"/>
        </LinearLayout>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_weight="1"
            android:orientation="vertical"
            android:layout_height="match_parent">
            <ImageView
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginTop="8dp"
                android:src="@drawable/look"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="看"
                android:layout_marginTop="8dp"
                android:gravity="center_horizontal"
                android:textColor="#444"/>
        </LinearLayout>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#fff"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:orientation="horizontal"
            android:paddingLeft="15dp"
            android:paddingRight="10dp">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="45dp">
                <ImageView
                    android:id="@+id/iv"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:src="@drawable/earlybird"
                    android:layout_gravity="center"/>
                <TextView
                    android:id="@+id/tv"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="45dp"
                    android:text="早鸟"
                    android:layout_marginLeft="20dp"
                    android:textSize="18sp"
                    android:gravity="center_vertical"/>
            </LinearLayout>
        </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:orientation="horizontal"
            android:paddingLeft="15dp"
            android:paddingRight="10dp">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="45dp">
                <ImageView
                    android:id="@+id/iv1"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:src="@drawable/angrybirds"
                    android:layout_gravity="center"/>
                <TextView
                    android:id="@+id/tv1"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="45dp"
                    android:text="愤怒的小鸟"
                    android:layout_marginLeft="20dp"
                    android:textSize="18sp"
                    android:gravity="center_vertical"/>
            </LinearLayout>
    </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="45dp"
            android:orientation="horizontal"
            android:paddingLeft="15dp"
            android:paddingRight="10dp">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="45dp">
                <ImageView
                    android:id="@+id/iv2"
                    android:layout_width="30dp"
                    android:layout_height="30dp"
                    android:src="@drawable/rope"
                    android:layout_gravity="center"/>
                <TextView
                    android:id="@+id/tv2"
                    android:layout_width="0dp"
                    android:layout_weight="1"
                    android:layout_height="45dp"
                    android:text="割绳子"
                    android:layout_marginLeft="20dp"
                    android:textSize="18sp"
                    android:gravity="center_vertical"/>
            </LinearLayout>
        </LinearLayout>

</LinearLayout>
</LinearLayout>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值