【移动应用开发】任务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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值