软件工程日报二十二——完善安卓界面

发布时间 2023-03-22 21:16:33作者: 伽澄

今天,我和我的搭档开始进行安卓地铁系统的编写,由于之前已经实现了个人作业,所以这次安卓界面的搭建比较容易

初版源码如下:

主页

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

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="地铁查询系统"
        android:textSize="50dp"
        android:textColor="@color/white"
        android:background="#E91E63"
        android:gravity="center">>

    </TextView>
    </LinearLayout>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/add"
        android:text="线路查询"
        android:textColor="@color/white">

    </Button>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/clock"
        android:text="站点查询"
        android:textColor="@color/white">

    </Button>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/query"
        android:text="换乘查询"
        android:textColor="@color/white">

    </Button>

</LinearLayout>

换乘查询

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ChangeQuery">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="换乘查询"
        android:id="@+id/title"
        android:textSize="30sp"
        android:textColor="@color/white"
        android:background="#E91E63"
        android:gravity="center">
    </TextView>

    <LinearLayout
        android:layout_below="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:layout_editor_absoluteX="135dp"
        tools:layout_editor_absoluteY="342dp">


        <TextView
            android:layout_width="match_parent"
            android:layout_height="70dp"
            android:id="@+id/a"
            android:text="请输入起点:"
            android:textSize="20dp" />

        <EditText
            android:id="@+id/querydata1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:inputType="text"
            ></EditText>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="70dp"
            android:id="@+id/b"
            android:text="请输入终点:"
            android:textSize="20dp" />

        <EditText
            android:id="@+id/querydata2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:inputType="text"
            ></EditText>

        <Button
            android:id="@+id/submit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="确定" />
        <Button
            android:id="@+id/back"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:text="返回"
            />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >


        </LinearLayout>

    </LinearLayout>

</RelativeLayout>

线路查询

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".queryActivity">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="线路查询"
        android:id="@+id/title"
        android:textSize="30sp"
        android:textColor="@color/white"
        android:background="#E91E63"
        android:gravity="center">
    </TextView>

    <LinearLayout
        android:layout_below="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:layout_editor_absoluteX="135dp"
        tools:layout_editor_absoluteY="342dp">


        <TextView
            android:layout_width="match_parent"
            android:layout_height="70dp"
            android:id="@+id/a"
            android:text="请输入线路号:"
            android:textSize="20dp" />

        <EditText
            android:id="@+id/querydata"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:inputType="text"
            ></EditText>

        <Button
            android:id="@+id/submit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="确定" />
        <Button
            android:id="@+id/back"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:text="返回"
            />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:textSize="18dp"
                android:id="@+id/show1"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:textSize="18dp"
                android:id="@+id/show2"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:textSize="18dp"
                android:id="@+id/show3"/>
        </LinearLayout>

    </LinearLayout>

</RelativeLayout>

站点查询

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ChangeQuery">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="站点查询"
        android:id="@+id/title"
        android:textSize="30sp"
        android:textColor="@color/white"
        android:background="#E91E63"
        android:gravity="center">
    </TextView>

    <LinearLayout
        android:layout_below="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        tools:layout_editor_absoluteX="135dp"
        tools:layout_editor_absoluteY="342dp">


        <TextView
            android:layout_width="match_parent"
            android:layout_height="70dp"
            android:id="@+id/a"
            android:text="请输入站点名:"
            android:textSize="20dp" />

        <EditText
            android:id="@+id/querydata"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:inputType="text"
            ></EditText>

        <Button
            android:id="@+id/submit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="确定" />
        <Button
            android:id="@+id/back"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:text="返回"
            />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:textSize="18dp"
                android:id="@+id/show1"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:textSize="18dp"
                android:id="@+id/show2"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:gravity="center"
                android:textSize="18dp"
                android:id="@+id/show3"/>
        </LinearLayout>

    </LinearLayout>

</RelativeLayout>

页面展示如下:

 

 

实现线路查询

 

 

对于以上安卓端的开发只是一个雏形,页面有些简陋,后期会继续进行开发。