第一个Android应用小程序

  • 实验目标

仿微信“发现”页创建列表布局

页面上主要包含5组列表,每组列表包含1-2个列表项。

 具体内容解释如下:

 • 列表组1:“朋友圈”单行列表项;

 • 列表组2:“扫一扫”和“摇一摇”两行列表项;

 • 列表组3:“看一看”和“搜一搜”两行列表项;

 • 列表组4:“购物”和“游戏”两行列表项;

 • 列表组5:“小程序”单行列表项。

二、实验步骤

(1)首先设计一个外部总垂直布局,包含所有的列表组

创建父布局,对父布局进行设置背景色为#e5e5e5,设置父布局的垂直方向。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:background="#e5e5e5"
    android:layout_height="match_parent"
    android:orientation="vertical">

构建第一个列表组

设置宽高背景色垂直方向

    <LinearLayout
        android:layout_marginTop="10dp"
        android:background="#fff"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="60dp">

创建列表组里的第一个图标

设置宽高、背景色、与左边的距离并且居中。

        <ImageView
            android:layout_marginLeft="15dp"
            android:layout_gravity="center_vertical"
            android:background="@mipmap/icon_pengyou"
            android:layout_width="40dp"
            android:layout_height="40dp"/>

创建列表组中的汉字

设置汉字宽高字体颜色字体样式字体大小与左侧的距离并且字体居中

        <TextView
            android:layout_width="329dp"
            android:layout_height="match_parent"
            android:layout_marginLeft="10dp"
            android:layout_weight="1"
            android:gravity="center_vertical"
            android:text="朋友圈"
            android:textColor="#333"
            android:textSize="18dp"
            android:textStyle="bold" />

创建列表组右边的箭头

设置宽和高背景水平居中与右边的距离

        <ImageView
            android:layout_marginRight="15dp"
            android:layout_gravity="center_vertical"
            android:background="@mipmap/right"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

  1. 同理,设置列表2、3、4、5。两个LinearLayout之间的间距可以通过如android:layout_marginTop="20dp"来控制间距大小。

三、程序运行结果

列出程序的最终运行结果及截图。

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值