移动软件开发实验6

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

一、实验目标

做一个APP首页,包括顶部图片、顶部菜单栏、中部消息模块、底部Tab按钮。学习 ScrollView, RelativeLayout,以及插件之间的穿插使用。

二、实验步骤

1、页面设计

页面上可以分为四个部分:

  • 顶部图片模块
  • 顶部菜单模块
  • 待办消息模块
  • 底部Tab按钮

2、逻辑梳理

  • ScrollView 使用
  • RelativeLayout 使用
  • 插件之间的穿插使用

3、代码实现

  • 首先我们创建他们的父布局
  • 新建ScrollView ,创建ScrollView 内部父布局,创建顶部首页显示栏,创建顶部图片
  • 菜单栏模块,首先我们创建一个横向的LinearLayoutLinearLayout来作为菜单栏的父布局,再次创建一个LinearLayout作为单个按钮的父布局,创建上边的图片按钮,并设置其属性,设置按钮底部文字并赋予其属性
  • 消息模块,首先我们创建一个横向的LinearLayout来作为菜单栏的父布局,创建待办Textview,创建更多Textview
  • 底部Tab模块,首先我们创建一个横向的LinearLayoutLinearLayout来作为菜单栏的父布局,再次创建一个LinearLayout作为单个按钮的父布局
    按钮

activity_main.xml代码如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <!--创建父布局-->
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="#f7f6fb">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:gravity="center"
                android:text="首页"
                android:textColor="#333"
                android:textSize="22dp"
                android:textStyle="bold" />

            <ImageView
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:src="@drawable/test_img" />
            <!--菜单栏模块-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:orientation="horizontal"
                android:weightSum="4">
                <!--验房-->
                <RelativeLayout
                    android:layout_width="0dp"
                    android:layout_height="100dp"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@id/image1"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_centerHorizontal="true"
                        android:layout_marginTop="10dp"
                        android:background="@drawable/test_icon1" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_below="@+id/image1"
                        android:layout_marginTop="10dp"
                        android:gravity="center"
                        android:text="验房"
                        android:textColor="@color/black"/>
                </RelativeLayout>
                <!--日常巡检-->
                <RelativeLayout
                    android:layout_width="0dp"
                    android:layout_height="100dp"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@id/image2"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_centerHorizontal="true"
                        android:layout_marginTop="10dp"
                        android:background="@drawable/test_icon2" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_below="@+id/image2"
                        android:layout_marginTop="10dp"
                        android:gravity="center"
                        android:text="日常巡检"
                        android:textColor="@color/black"/>
                </RelativeLayout>
                <!--钥匙管理-->
                <RelativeLayout
                    android:layout_width="0dp"
                    android:layout_height="100dp"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@id/image3"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_centerHorizontal="true"
                        android:layout_marginTop="10dp"
                        android:background="@drawable/yaoshi" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_below="@+id/image3"
                        android:layout_marginTop="10dp"
                        android:gravity="center"
                        android:text="钥匙管理"
                        android:textColor="@color/black"/>
                </RelativeLayout>
                <!--统计分析-->
                <RelativeLayout
                    android:layout_width="0dp"
                    android:layout_height="100dp"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <ImageView
                        android:id="@id/image4"
                        android:layout_width="50dp"
                        android:layout_height="50dp"
                        android:layout_centerHorizontal="true"
                        android:layout_marginTop="10dp"
                        android:background="@drawable/tongji" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:layout_below="@+id/image4"
                        android:layout_marginTop="10dp"
                        android:gravity="center"
                        android:text="统计分析"
                        android:textColor="@color/black"/>
                </RelativeLayout>
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:orientation="horizontal">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_weight="1"
                    android:text="待办(10)"
                    android:textColor="#333"
                    android:textSize="16dp"
                    android:textStyle="bold" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:text="更多"
                    android:textColor="#666" />
            </LinearLayout>

            <!--消息-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp">
                <LinearLayout
                        android:layout_width="300dp"
                        android:layout_height="90dp"
                        android:layout_marginLeft="30dp"
                        android:orientation="vertical"
                        android:layout_marginBottom="30dp"
                        android:background="#0099ff">
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:layout_marginBottom="-4dp"
                        android:text="*鼎世华府1号楼8单元801业主提报钥匙借用申请"
                        android:textColor="@color/black"/>


                </LinearLayout>
                <LinearLayout
                    android:layout_width="300dp"
                    android:layout_height="90dp"
                    android:orientation="vertical"
                    android:layout_marginLeft="30dp"
                    android:layout_marginBottom="20dp"
                    android:background="#CCCCFF">
                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="50dp"
                        android:layout_marginBottom="-4dp"
                        android:text="*海尔世纪公馆1期12号楼3单元101房间问题待指派"
                        android:textColor="@color/black"/>
                </LinearLayout>

            </LinearLayout>



        </LinearLayout>
    </ScrollView>

    <!--底部按钮-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:layout_gravity="bottom"
        android:layout_weight="0"
        android:weightSum="4">

        <RelativeLayout
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="match_parent">

            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginTop="15dp"
                android:layout_centerHorizontal="true"
                android:id="@+id/image1"
                android:src="@drawable/test_icon3" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/image1"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="5dp"
                android:gravity="center"
                android:text="首页" />
        </RelativeLayout>
        <RelativeLayout
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="match_parent">

            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginTop="15dp"
                android:layout_centerHorizontal="true"
                android:id="@+id/image2"
                android:src="@drawable/daiban" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/image2"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="5dp"
                android:gravity="center"
                android:text="验房" />
        </RelativeLayout>
        <RelativeLayout
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="match_parent">

            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginTop="15dp"
                android:layout_centerHorizontal="true"
                android:id="@+id/image3"
                android:src="@drawable/baobiao" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/image3"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="5dp"
                android:gravity="center"
                android:text="统计" />
        </RelativeLayout>
        <RelativeLayout
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="match_parent">

            <ImageView
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_marginTop="15dp"
                android:layout_centerHorizontal="true"
                android:id="@+id/image4"
                android:src="@drawable/guanli" />

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/image4"
                android:layout_centerHorizontal="true"
                android:gravity="center"
                android:text="设置" />
        </RelativeLayout>

    </LinearLayout>


</LinearLayout>

三、程序运行结果

[外链图片转存中...(img-zVzt99Rt-1661438006792)]

四、问题总结与体会

  • 本次实验仅涉及UI设计,未涉及后端相关功能,较为简单。本次实验学习了ScrollView 使用和RelativeLayout 使用。

  • RelativeLayout,顾名思义,相对布局,也是非常常用的布局,他比LinearLayout更加灵活,可以实现非常复杂的UI。

  • ScrollView是一种特殊的布局。当ScrollView的内容大于他本身的size的时候,ScrollView会自动添加滚动条,并可以竖直滑动。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值