实现一个计算器的例子

实现一个计算器的例子,第1张

概述layoutabsolute_layout<?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apkes/android"android:orientation="vertical"android:layout_width="matc

layout

absolute_layout

<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:orIEntation="vertical"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"><linearLayout    androID:layout_wIDth="match_parent"    androID:layout_height="80dp"    androID:orIEntation="horizontal">    <TextVIEw        androID:layout_wIDth="0dp"        androID:layout_height="match_parent"        androID:layout_weight="1"        androID:gravity="center"        androID:background="@drawable/shape_rectangle"        androID:text="C"        androID:textSize="30sp"/>    <TextVIEw        androID:layout_wIDth="0dp"        androID:layout_height="match_parent"        androID:layout_weight="1"        androID:gravity="center"        androID:background="@drawable/shape_rectangle"        androID:text="+/-"        androID:textSize="30sp"/>    <TextVIEw        androID:layout_wIDth="0dp"        androID:layout_height="match_parent"        androID:layout_weight="1"        androID:gravity="center"        androID:background="@drawable/shape_rectangle"        androID:text="%"        androID:textSize="30sp"/>    <TextVIEw        androID:layout_wIDth="0dp"        androID:layout_height="match_parent"        androID:layout_weight="1"        androID:gravity="center"        androID:background="@drawable/shape_rectangle_orange"        androID:text="÷"        androID:textSize="30sp"/></linearLayout>    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="80dp"        androID:orIEntation="horizontal">        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:background="@drawable/shape_rectangle"            androID:text="7"            androID:textSize="30sp"/>        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:background="@drawable/shape_rectangle"            androID:text="8"            androID:textSize="30sp"/>        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:background="@drawable/shape_rectangle"            androID:text="9"            androID:textSize="30sp"/>        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:background="@drawable/shape_rectangle_orange"            androID:text="×"            androID:textSize="30sp"/>    </linearLayout>    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="80dp"        androID:orIEntation="horizontal">        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:background="@drawable/shape_rectangle"            androID:text="4"            androID:textSize="30sp"/>        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:background="@drawable/shape_rectangle"            androID:text="5"            androID:textSize="30sp"/>        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:background="@drawable/shape_rectangle"            androID:text="6"            androID:textSize="30sp"/>        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:background="@drawable/shape_rectangle_orange"            androID:text="-"            androID:textSize="30sp"/>    </linearLayout>    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="80dp"        androID:orIEntation="horizontal">        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:background="@drawable/shape_rectangle"            androID:text="1"            androID:textSize="30sp"/>        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:background="@drawable/shape_rectangle"            androID:text="2"            androID:textSize="30sp"/>        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:text="3"            androID:background="@drawable/shape_rectangle"            androID:textSize="30sp"/>        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:background="@drawable/shape_rectangle_orange"            androID:text="+"            androID:textSize="30sp"/>    </linearLayout>    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="80dp"        androID:orIEntation="horizontal">        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="2"            androID:gravity="center_vertical"            androID:paddingleft="40dp"            androID:text="0"            androID:background="@drawable/shape_rectangle"            androID:textSize="30sp"/>        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:text="."            androID:background="@drawable/shape_rectangle"            androID:textSize="30sp"/>        <TextVIEw            androID:layout_wIDth="0dp"            androID:layout_height="match_parent"            androID:layout_weight="1"            androID:gravity="center"            androID:text="="            androID:background="@drawable/shape_rectangle"            androID:textSize="30sp"/>    </linearLayout></linearLayout>

 

drawable

shape_recangle.xml

<?xml version="1.0" enCoding="utf-8"?><shape xmlns:androID="http://schemas.androID.com/apk/res/androID">       androID:shape="rectangle">    <solID androID:color="#ffffff"/>    <stroke androID:color="#333333" androID:wIDth="1dp"/></shape>

shape_recangle_orange.xml

<?xml version="1.0" enCoding="utf-8"?><shape xmlns:androID="http://schemas.androID.com/apk/res/androID">       androID:shape="rectangle">    <solID androID:color="#e47f26"/>    <stroke androID:color="#333333" androID:wIDth="1dp"/></shape>

总结

以上是内存溢出为你收集整理的实现一个计算器例子全部内容,希望文章能够帮你解决实现一个计算器的例子所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1067897.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存