「牛角书」鸿蒙——简易指南针项目开发

zut_fyf
发布于 2022-12-17 21:26
浏览
0收藏

项目描述:

本项目是基于Java开发的一个鸿蒙程序小应用,实现一个简单的指南针,来演示传感器的常规使用方法(获取传感器并进行监听、取消监听等)。本项目可能存在着一些问题,大家可以帮忙指正。

项目运行结果:

「牛角书」鸿蒙——简易指南针项目开发-鸿蒙开发者社区

部分代码展示:

xml代码展示
<DirectionalLayout xmlns:ohos:height=“match_parent”
ohos:width=“match_parent”
ohos:orientation=“vertical”>
<Image
ohos:id=“$+id:compass_icon_img”
ohos:height=“300vp”
ohos:width=“300vp”
ohos:layout_alignment=“horizontal_center”
ohos:image_src=“$media:compass”/>
<Text
ohos:id=“$+id:compass_angle_text”
ohos:height=“match_content”
ohos:width=“match_content”
ohos:text_size=“30fp”
ohos:text_weight=“720”
ohos:layout_alignment=“horizontal_center”/>

<Text
    ohos:height="35vp"
    ohos:width="match_parent"
    ohos:text="Your Phone Status"
    ohos:text_alignment="center"
    ohos:text_size="22fp"
    ohos:top_margin="30vp"/>

<DirectionalLayout
    ohos:height="40vp"
    ohos:width="match_parent"
    ohos:orientation="horizontal"
    ohos:top_margin="15vp">

    <Text
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:start_padding="15vp"
        ohos:end_padding="0vp"
        ohos:text="WiFi_Status: "
        ohos:text_size="16fp"/>

    <Text
        ohos:id="$+id:wifi_status"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:text_color="#7B7B7B"
        ohos:text_size="16fp"/>
</DirectionalLayout>

<DirectionalLayout
    ohos:height="40vp"
    ohos:width="match_parent"
    ohos:orientation="horizontal">

    <Text
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:start_padding="15vp"
        ohos:end_padding="0vp"
        ohos:text="Bluetooth_Status: "
        ohos:text_size="16fp"/>

    <Text
        ohos:id="$+id:bluetooth_status"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:text_color="#7B7B7B"
        ohos:text_size="16fp"/>
</DirectionalLayout>

<DirectionalLayout
    ohos:height="40vp"
    ohos:width="match_parent"
    ohos:orientation="horizontal">

    <Text
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:start_padding="15vp"
        ohos:end_padding="0vp"
        ohos:text="Airplane_Status: "
        ohos:text_size="16fp"/>

    <Text
        ohos:id="$+id:airplane_mode_status"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:text_color="#7B7B7B"
        ohos:text_size="16fp"/>
</DirectionalLayout>


<DirectionalLayout
    ohos:height="40vp"
    ohos:width="match_parent"
    ohos:orientation="horizontal">

    <Text
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:start_padding="15vp"
        ohos:end_padding="0vp"
        ohos:text="Country: "
        ohos:text_size="16fp"/>

    <Text
        ohos:id="$+id:country_text"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:text_color="#7B7B7B"
        ohos:text_size="16fp"/>
</DirectionalLayout>

<DirectionalLayout
    ohos:height="40vp"
    ohos:width="match_parent"
    ohos:orientation="horizontal">

    <Text
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:start_padding="15vp"
        ohos:end_padding="0vp"
        ohos:text="Language: "
        ohos:text_size="16fp"/>

    <Text
        ohos:id="$+id:language_text"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:text_color="#7B7B7B"
        ohos:text_size="16fp"/>
</DirectionalLayout>

<DirectionalLayout
    ohos:height="40vp"
    ohos:width="match_parent"
    ohos:orientation="horizontal">

    <Text
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:start_padding="15vp"
        ohos:end_padding="0vp"
        ohos:text="Time_Zone: "
        ohos:text_size="16fp"/>

    <Text
        ohos:id="$+id:timezone_text"
        ohos:height="match_content"
        ohos:width="match_content"
        ohos:text_color="#7B7B7B"
        ohos:text_size="16fp"/>
</DirectionalLayout>

</DirectionalLayout>

总结:

由于鄙人才疏学浅,致使本项目还有许多不完美之处,谢谢大家。

标签
收藏
回复
举报
回复
    相关推荐