当前位置: 首页 > news >正文

【移动应用开发】任务4 创建系统主界面

目录

最终效果呈现 

需要用到的素材图片

1、选择主界面布局方式

2、添加环境监控布局

3、添加禁入监控区域布局

4、添加设备控制区域

(1)新建drawable-xhdpi文件夹

(2)编写strings.xml文件,添加下面代码

(3)编写activity_main.xml文件

5、三个文件的源码:

(1)strings.xml文件

(2)colors.xml文件

(3)activity_main.xml


最终效果呈现 

需要用到的素材图片

1、选择主界面布局方式

四个方位:Left Right Top Bottom

上一个splash界面选择了相对布局(RelativeLayout)

本节选择线性布局(LinearLayout): 线性布局会在水平或垂直方向上让视图相邻显示

如果是垂直方向:视图会显示在一列上,如果是垂直方向,视图会显示在一行上

线性布局有个重要的属性:orientation 它的取值有两个:

vertical:垂直方向

horizontal:水平方向

2、添加环境监控布局

<!-- Ctrl+/ 注释   -->
<!--    欢迎使用智慧工厂应用-->
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="欢迎使用智慧工厂应用"
        android:textAlignment="center"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:textSize="20sp"
        android:background="@color/colorPrimaryDark"
        android:textColor="@color/white"/>

<!--    温度,湿度,光照布局-->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingTop="20dp"
        android:paddingBottom="20dp"
        android:paddingLeft="10dp"
        android:paddingRight="10dp"
        android:orientation="horizontal">
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="16sp"
            android:text="@string/temperature_title"/>
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="16sp"
            android:textColor="@color/colorRed"
            android:text="@string/temperature_value"/>
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="16sp"
            android:text="@string/humility_title"/>
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:textSize="16sp"
            android:textColor="@color/colorRed"
            android:text="@string/humility_value"/>
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textSize="16sp"
            android:text="@string/light_title"/>
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:textSize="16sp"
            android:textColor="@color/colorRed"
            android:text="@string/light_value"/>
    </LinearLayout>

相关文章:

  • 【AVRCP】深度解析蓝牙高速(AMP)在封面艺术传输中的应用:低延迟体验的工程实践
  • java使用小知识合集(持续更新中)
  • etcd性能测试
  • 前端空白/红幕报错 undefined
  • Tensorrt的安装、转化、以及推理
  • 李飞飞、吴佳俊团队新作:FlowMo如何以零卷积、零对抗损失实现ImageNet重构新巅峰
  • 虚拟机(二):Android 篇
  • 【春招笔试】阿里云2025.03.20
  • 用C#实现UDP服务器
  • 线程概念与控制(上)
  • 小智AI音频开发 libopus + Eclipse C/C++ MinGW 编解码测试用例
  • Leetcode 最小基因变化
  • 鸿蒙生态圈暗战:数字孪生三强争霸谁将主宰消费电子未来?
  • 【MySQL数据库】视图 + 三范式
  • Zabbix监控K8s集群
  • C语言do...while语句将数字反转后输出
  • Linux内核NIC网卡驱动实战案例分析
  • 【AI】先搞明白MCP、 API、ANP、Agora、agents.json、LMOS、AITP开源通信协议再学大模型
  • “十五五”时期航空弹药发展环境分析
  • 生物化学笔记:医学免疫学原理06 抗体药物 多克隆抗体+单克隆抗体(各代单克隆抗体发展历程)
  • 冯德莱恩:欧美贸易谈判前不会前往美国会见特朗普
  • 上海市委常委会会议暨市生态文明建设领导小组会议研究基层减负、生态环保等事项
  • 读图|展现城市品格,上海城市影像走进南美
  • 第1现场 | 印巴冲突:印50多年来首次举行大规模民防演习
  • 中消协点名新能源汽车行业:定金退款争议频发
  • 司法部:加快研究制定行政执法监督条例,建立完善涉企行政执法监督长效机制