Android开发实用小工具九——温度转换工具


前言

温度转换工具的开发与实现。


一、效果展示

温度转换工具的开发与实现
温度转换工具的开发与实现

二、代码

准备工作与我开发的另一个小工具(长度转换工具)所用一致,详情请看我上一篇文章。
链接: Android开发实用小工具二——长度转换工具

1.样式布局

本项目相较于前几个小工具的开发,多了一个数值取反的功能。

res/layout/activity_value_conversion.xml :

<?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:background="#ffe9ecf1"
    android:orientation="vertical">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#ffffffff">

        <ImageView
            android:id="@+id/iv_back"
            android:layout_width="40dp"
            android:layout_height="match_parent"
            android:layout_alignParentLeft="true"
            android:padding="10dp"
            android:scaleType="fitCenter"
            android:src="@drawable/ic_back" />

        <TextView
            android:id="@+id/tv_title"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_centerInParent="true"
            android:gravity="center"
            android:text="温度转换工具"
            android:textColor="#ff000000"
            android:textSize="17sp" />

    </RelativeLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal">

        <Spinner
            android:id="@+id/sp_select1"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="5"
            android:dropDownWidth="215dp"
            android:popupBackground="@drawable/shape_module"
            android:spinnerMode="dropdown" />

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="6"
            android:orientation="vertical">

            <TextView
                android:id="@+id/tv_value1"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginRight="10dp"
                android:layout_weight="2"
                android:gravity="right|bottom"
                android:text="0"
                android:textColor="#ffff8800"
                android:textSize="30sp" />

            <TextView
                android:id="@+id/tv_unit1"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginRight="10dp"
                android:layout_weight="1"
                android:gravity="right"
                android:textColor="#FF959595"
                android:textSize="13sp"
                tools:text="m" />

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:orientation="horizontal">

        <Spinner
            android:id="@+id/sp_select2"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="5"
            android:dropDownWidth="215dp"
            android:popupBackground="@drawable/shape_module"
            android:spinnerMode="dropdown" />

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="6"
            android:orientation="vertical">

            <TextView
                android:id="@+id/tv_value2"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginRight="10dp"
                android:layout_weight="2"
                android:gravity="right|bottom"
                android:text="0"
                android:textColor="#ff000000"
                android:textSize="30sp" />

            <TextView
                android:id="@+id/tv_unit2"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginRight="10dp"
                android:layout_weight="1"
                android:gravity="right"
                android:textColor="#FF959595"
                android:textSize="13sp"
                tools:text="chi" />

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/shape_module"
        android:orientation="horizontal"
        android:padding="20dp">

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="3"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:orientation="horizontal"
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

此名哥已占

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值