首页 > 其他分享 >2022-10-14学习内容

2022-10-14学习内容

时间:2022-10-14 23:11:28浏览次数:49  
标签:xml 10 14 没敲 2022 计算器

1.案例-计算器-界面编码

1.1activity_calculator.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#EEEEEE"
    android:orientation="vertical"
    android:padding="5dp">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/simple_calculator"
                android:gravity="center"
                android:textColor="@color/black"
                android:textSize="20sp" />

            <TextView
                android:id="@+id/tv_result"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/white"
                android:gravity="right|bottom"
                android:lines="3"
                android:text="0"
                android:textColor="@color/black"
                android:textSize="25sp"/>

            <GridLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:columnCount="4"
                android:rowCount="5">

                <Button
                    android:id="@+id/btn_cancel"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/cancel"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_divide"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/divide"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_multiply"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/multiply"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_clear"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/clear"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_seven"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/seven"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>
                <Button
                    android:id="@+id/btn_eight"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/eight"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_nine"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/nine"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_plus"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/plus"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_four"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/four"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_five"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/five"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_six"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/six"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_minus"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/minus"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_one"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/one"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_two"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/two"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_three"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/three"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <ImageButton
                    android:id="@+id/ib_sqrt"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:scaleType="centerInside"
                    android:src="@drawable/sqrt" />

                <Button
                    android:id="@+id/btn_reciprocal"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/reciprocal"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_zero"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/zero"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_dot"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/dot"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

                <Button
                    android:id="@+id/btn_equal"
                    android:layout_width="0dp"
                    android:layout_height="@dimen/button_height"
                    android:layout_columnWeight="1"
                    android:gravity="center"
                    android:text="@string/equal"
                    android:textColor="@color/black"
                    android:textSize="@dimen/button_font_size"/>

            </GridLayout>

        </LinearLayout>

    </ScrollView>

</LinearLayout>

1.2strings.xml

<resources>
    <string name="app_name">chapter03</string>
    <string name="hello">你好,世界</string>
    <string name="simple_calculator">简易计算器</string>
    <string name="cancel">CE</string>
    <string name="divide">/</string>
    <string name="multiply">*</string>
    <string name="clear">C</string>
    <string name="seven">7</string>
    <string name="eight">8</string>
    <string name="nine">9</string>
    <string name="plus">+</string>
    <string name="four">4</string>
    <string name="five">5</string>
    <string name="six">6</string>
    <string name="minus">-</string>
    <string name="one">1</string>
    <string name="two">2</string>
    <string name="three">3</string>
    <string name="reciprocal">1/x</string>
    <string name="zero">0</string>
    <string name="dot">.</string>
    <string name="equal">=</string>
</resources>

1.3dimens.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    
    <dimen name="button_font_size">30sp</dimen>
    <dimen name="button_height">75dp</dimen>
    
</resources>

1.4效果(备注:后端逻辑代码没敲完,先把这一节的页面发出来)

 

标签:xml,10,14,没敲,2022,计算器
From: https://www.cnblogs.com/pingfanliliang/p/16790287.html

相关文章

  • 10.14随笔
    符号名称SI量纲含义E电场强度V/mqE=电荷上的电力D电激发As/m^2产生场的电荷是这个场的源P极化As/m^2偶极矩/体积B磁场强度T(特斯拉)=Vs/m^2q(v......
  • 2022-2023-1 20221322《计算机基础与程序设计》第七周学习总结
    作业信息这个作业属于哪个课程<班级的链接>(2022-2023-1-计算机基础与程序设计)这个作业要求在哪里<作业要求的链接>(2022-2023-1计算机基础与程序设计第七周作业......
  • Linux系统编程10-模拟实现 ls -l 命令
    //-rw-rw-r--1usernamegroupname112WedSep1422:08:302022hello.txt#include<stdio.h>#include<sys/types.h>#include<sys/stat.h>#include<unistd.h>#......
  • Linux系统编程14-rename
    #include<stdio.h>intrename(constchar*oldpath,constchar*newpath);作用:重命名文件或文件夹返回值:执行成功则返回0,失败返回-1,错误原因存于errno实例:重命名目......
  • vp训练 | 2022 江苏省赛 A C I J K L
    A.PENTAKILL!题意:给定一个击杀序列,死亡不影响连杀,问是否有人完成五杀分析:模拟,将每个选手的名字进行哈希,将属于每一个人的击杀序列处理出来,对每个人进行枚举判断即可ac......
  • 【闲话】2022.10.14
    今天的考试可算是寄大方了以及:已知T1时限6s,T2T3T4时限均为2s,且每道题都有100个数据点。现在有3页提交。请问Accoders什么时候会炸?真的有一说一,性能不如......
  • 10月14日周赛
    今天又有周赛。第1、2题我做的很快。第3题遇到了问题,开始只得了10分,我不断修改,变成了80分。第4题,我把题目读懂了,就是在一个区间里找数,这数要像山峦一样,有小到大。开始得......
  • 2022.10.14
    今天是我写博客的第一天,首先最重要的就是团队,已经有380人啦,我们的公开赛依然在审核中,已经过去一周了还没有审核好,其次今天在学校里得知我下个星期就要跑1000米了,呜呜呜,而且......
  • 2022.10 杂题
    P8569[JRKSJR6]第七学区首先,有若干种\(O(n\logV)\)的暴力。我们选择其中操作比较简单的一种:对于每一位,先求出所有\(0\)段的长度之和,然后用所有区间的长度之和减掉......
  • 2022-10-14
    30F:三笔,中枢构筑中  5F:已经2中枢,有背驰迹象,预计30F一笔将结束  计划:1.如果再次冲高,可空30F一笔2.等30F回调一笔,小级别入场做多......