微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

《移动软件开发》实验五

2022年夏季《移动软件开发》实验报告

一、实验目标

1、Textview imageview 使用;2、LinearLayout 使用;

二、实验步骤

列出实验的关键步骤、代码解析、截图。

1.TextView了解

​ match_parent: 自适应满屏

​ wrap_content: 自适应大小

​ layout_width:宽

5_1

​ layout_height:高

​ text: 所展现的字

​ textSize: 字体大小

​ textColor:字体颜色

​ textStyle:字体样式 (italic:倾斜,bold:加粗,)

​ gravity:在控件内部的位置(通用)

​ layout_margin:与其他控件的距离 (通用)

​ padding:内部间隔距离

​ layout_width:宽

​ layout_height:高

​ background:背景

​ src:加载图片,不会拉伸

5_2

2.LinearLayout了解

​ 布局特点:放主要提供控件水平或者垂直排列的模型,每个子组件

​ layout_width:宽

​ layout_height:高

​ orientation:垂直方向(vertical:纵向,horizontal横向)

5_3

3.功能实现

​ 3.1逻辑梳理

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

​ 具体内容解释如下:

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

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

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

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

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

5_4

​ 首先设计一个外部总垂直布局,包含所有的列表组,写五个LinearLayout来构建这五个列表组,每个列表组的单独构建列表组之间的间隔样式搭建。

​ 3.2代码实现

​ 3.2.1首先我们创建他们的父布局,对父布局进行设置背景色,设置父布局的垂直方向

5_5

​ 3.2.2构建第一个列表组,设置宽高,设置背景色,设置垂直方向

5_6

​ 3.2.3创建列表组里的第一个图标,设置宽高,设置背景色,设置与左边的距离,设置居中

5_7

​ 3.2.4创建列表组中的汉字,设置汉字,设置宽高,设置字体颜色,设置字体样式,设置字体大小,设置与左侧的距离,设置字体居中

5_8

​ 3.2.5创建列表组右边的箭头,设置宽和高,设置背景,设置水平居中,设置与右边的距离

5_9

三、程序运行结果

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

5_10

代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f0f0f0"
    android:orientation="vertical"
    tools:context=".MainActivity">


    <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:textColor="#333"
            android:textStyle="bold"
            android:textSize="18dp"
            android:layout_marginLeft="15dp"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="朋友圈"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>


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


    </LinearLayout>


    <TextView
        android:background="#f0f0f0"
        android:layout_width="wrap_content"
        android:layout_height="25dp"/>


    <LinearLayout
        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/saoyisao"
            android:layout_width="40dp"
            android:layout_height="40dp"/>

        <TextView
            android:textColor="#333"
            android:textStyle="bold"
            android:textSize="18dp"
            android:layout_marginLeft="15dp"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="扫一扫"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>


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


    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="0dp"
        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/yaoyiyao"
            android:layout_width="40dp"
            android:layout_height="40dp"/>

        <TextView
            android:textColor="#333"
            android:textStyle="bold"
            android:textSize="18dp"
            android:layout_marginLeft="15dp"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="摇一摇"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>


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


    </LinearLayout>

    <LinearLayout
        android:layout_marginTop="25dp"
        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/kanyikan"
            android:layout_width="40dp"
            android:layout_height="40dp"/>

        <TextView
            android:textColor="#333"
            android:textStyle="bold"
            android:textSize="18dp"
            android:layout_marginLeft="15dp"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="看一看"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>


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


    </LinearLayout>
    <LinearLayout
        android:layout_marginTop="0dp"
        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/souyisou"
            android:layout_width="40dp"
            android:layout_height="40dp"/>

        <TextView
            android:textColor="#333"
            android:textStyle="bold"
            android:textSize="18dp"
            android:layout_marginLeft="15dp"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="搜一搜"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>


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


    </LinearLayout>
    <LinearLayout
        android:layout_marginTop="25dp"
        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/gouwu"
            android:layout_width="40dp"
            android:layout_height="40dp"/>

        <TextView
            android:textColor="#333"
            android:textStyle="bold"
            android:textSize="18dp"
            android:layout_marginLeft="15dp"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="购物"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>


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


    </LinearLayout>
    <LinearLayout
        android:layout_marginTop="0dp"
        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/youxi"
            android:layout_width="40dp"
            android:layout_height="40dp"/>

        <TextView
            android:textColor="#333"
            android:textStyle="bold"
            android:textSize="18dp"
            android:layout_marginLeft="15dp"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="游戏"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>


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


    </LinearLayout>
    <LinearLayout
        android:layout_marginTop="25dp"
        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/xiaochengxu"
            android:layout_width="40dp"
            android:layout_height="40dp"/>

        <TextView
            android:textColor="#333"
            android:textStyle="bold"
            android:textSize="18dp"
            android:layout_marginLeft="15dp"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:text="小程序"
            android:layout_width="0dp"
            android:layout_height="wrap_content"/>


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


    </LinearLayout>
</LinearLayout>

四、问题总结与体会

描述实验过程中所遇到的问题,以及是如何解决的。有哪些收获和体会,对于课程的安排有哪些建议。

这次实验主要是了解了Textview imageview 使用和LinearLayout 使用。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐