1.activity_main.xml文件布局

<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:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <EditText
android:layout_width="fill_parent"
android:layout_height="90dp"
android:gravity="right|center_vertical"
android:id="@+id/edit_text1"
android:background="@drawable/white_bg"/> <LinearLayout
android:layout_marginTop="10dp"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:id="@+id/ll1"
android:orientation="horizontal"
>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="C"
android:textSize="30sp"
android:id="@+id/bt_clear"
/>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="DEL"
android:textSize="30sp"
android:id="@+id/bt_del"
/>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="÷"
android:textSize="30sp"
android:id="@+id/bt_divide"
/>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="×"
android:textSize="30sp"
android:id="@+id/bt_multipy"
/> </LinearLayout> <LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:id="@+id/ll2"
android:orientation="horizontal"
>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="7"
android:textSize="30sp"
android:id="@+id/bt_7"
/>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="8"
android:textSize="30sp"
android:id="@+id/bt_8"
/>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="9"
android:textSize="30sp"
android:id="@+id/bt_9"
/>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="-"
android:textSize="30sp"
android:id="@+id/bt_minuse"
/> </LinearLayout> <LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:id="@+id/ll3"
android:layout_below="@id/ll2"
android:orientation="horizontal"
>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="4"
android:textSize="30sp"
android:id="@+id/bt_4"
/>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="5"
android:textSize="30sp"
android:id="@+id/bt_5"
/>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="6"
android:textSize="30sp"
android:id="@+id/bt_6"
/>
<Button
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:text="+"
android:textSize="30sp"
android:id="@+id/bt_plus"
/> </LinearLayout> <LinearLayout
android:layout_weight="2"
android:layout_width="fill_parent"
android:layout_height="0dp">
<LinearLayout
android:orientation="vertical"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="fill_parent"> <LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="0dp">
<Button
android:layout_weight="1"
android:id="@+id/btn_1"
android:text="1"
android:textSize="30sp"
android:layout_width="0dp"
android:layout_height="fill_parent" />
<Button
android:layout_weight="1"
android:id="@+id/btn_2"
android:text="2"
android:textSize="30sp"
android:layout_width="0dp"
android:layout_height="fill_parent" />
<Button
android:layout_weight="1"
android:id="@+id/btn_3"
android:text="3"
android:textSize="30sp"
android:layout_width="0dp"
android:layout_height="fill_parent" />
</LinearLayout> <LinearLayout
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="0dp">
<Button
android:layout_weight="2"
android:id="@+id/btn_0"
android:text="0"
android:textSize="30sp"
android:layout_width="0dp"
android:layout_height="fill_parent" />
<Button
android:layout_weight="1"
android:id="@+id/btn_point"
android:text="."
android:textSize="30sp"
android:layout_width="0dp"
android:layout_height="fill_parent" />
</LinearLayout> </LinearLayout> <LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="fill_parent">
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="="
android:id="@+id/btn_dengyu"
android:textSize="30sp"
/> </LinearLayout>
</LinearLayout> </LinearLayout> </LinearLayout>

  

2.mainfest.xml设置

<activity
android:theme="@android:style/Theme.Black.NoTitleBar"/> //主题 黑色 没有标题

3.color.xml的写法

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#ffffff</color>
<color name="black">#000000</color>
</resources>

4.drawable 下创建 white_bg.xml作为EditText白色背景

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="5dp"/>    //角 半径5dp 圆角
<solid                  //填充色
android:color="@color/white"
/>  
</shape>

  

①<corners/>:设置圆角。android:radius="5dp":圆角半径为5dp。
②<gradient/>:图像颜色的渐变。开始颜色:startColor="@color/white"。结束颜色:endColor="@color/red"
③<stroke/>:边框。width="1dp":边框宽度。color="@color/black":边框颜色。
④<solid/>:填充色。color="@color/white":填充色为白色。

Android 计算器制作 1.布局的更多相关文章

  1. Android 计算器制作 2.注册View 构建函数

    鄙人新手 整了 快两天 终于搞定了.. 1.首先是MainActivity 中 在Oncreate函数中 注册 2.按+ 或者 - 号 来分成两大字符串 s1 和 s2 再将s2 分为更小的s1 和 ...

  2. Android计算器布局

    Android(安桌)计算器布局实现         ——解决整个屏幕方案 引言:     学完了android布局的几种方式,做了一个android计算器. 我在网上搜索了这方面的资料,发现了布局都 ...

  3. Flexbox制作CSS布局实现水平垂直居中

    Flexbox实现一个div元素在body页面中水平垂直居中: <!DOCTYPE html><html lang="en"><head>  & ...

  4. Android中制作自定义dialog对话框的实例

    http://www.jb51.net/article/83319.htm   这篇文章主要介绍了Android中制作自定义dialog对话框的实例分享,安卓自带的Dialog显然不够用,因而我们要继 ...

  5. Android计算器简单逻辑实现

    Android计算器简单逻辑实现 引言: 我的android计算器的实现方式是:按钮输入一次,就处理一次. 但是如果你学过数据结构(栈),就可以使用表达式解析(前缀,后缀)处理. 而这个方式已经很成熟 ...

  6. Android模板制作

    本文详细介绍模板相关的知识和如何制作Android模版及使用,便于较少不必要的重复性工作.比如我在工作中如果要创建一个新的模块,就不要需要创建MVP相关的几个类:Model.View.Presente ...

  7. Android中的LinearLayout布局

    LinearLayout : 线性布局 在一般情况下,当有很多控件需要在一个界面列出来时,我们就可以使用线性布局(LinearLayout)了,  线性布局是按照垂直方向(vertical)或水平方向 ...

  8. Android开发-之五大布局

    在html中大家都知道布局是什么意思了,简单来说就是将页面划分模块,比如html中的div.table等.那么Android中也是这样的.Android五大布局让界面更加美化,开发起来也更加方便.当然 ...

  9. 简单研究Android View绘制三 布局过程

    2015-07-28 17:29:19 这一篇主要看看布局过程 一.布局过程肯定要不可避免的涉及到layout()和onLayout()方法,这两个方法都是定义在View.java中,源码如下: /* ...

随机推荐

  1. 【JVM学习笔记】ServiceLoader类

    ServiceLoader.load方法的函数原型如下 public static <S> ServiceLoader<S> load(Class<S> servi ...

  2. 软件开发的SOLID原则

    再次回顾以前潘加宇老师将的软件开放的原则. SOLID: 单一责任原则 S 开放封闭原则 O 里氏代换原则 L 接口分离原则 I 依赖反转原则 D 所有编程都是维护编程,因为你很少写原创代码.只有你在 ...

  3. golang 操作ceph object storage

    ceph的object storage 提供了和amazon s3兼容的接口以供客户访问. 在ceph的官网上,可以看到它提供了多种语言的访问范本,例如python的(http://docs.ceph ...

  4. 关于Java新手开发配置各种环境可能会遇到的的坑

    一.软件的安装 虽然国内的软件都支持中文目录安装,部分国外软件也支持,但是作为一名合格的程序开发者,必须做到以下几点 Windows下开发软件的安装目录和环境变量中永远不要包含中文字符,包括汉字[]. ...

  5. k8s集群证书过期(kubeadm 1.10.2 )

    1.k8s 集群架构描述 kubeadm v1.10.2创建k8s集群. master节点高可用,三节点(10.18.60.3.10.18.60.4.10.18.60.5). LVS实现master三 ...

  6. 【Java开发】Maven那点事儿(Eclipse版)

    Maven那点事儿(Eclipse版) 前言: 由于最近工作学习,总是能碰到Maven的源码.虽然平时工作并不使用Maven,但是为了学习一些源码,还是必须要了解下.这篇文章不是一个全面的Maven解 ...

  7. airflow原理

    官网: http://airflow.apache.org/installation.html 原理: https://www.cnblogs.com/cord/p/9450910.html 原理介绍 ...

  8. (转)新手入局 你必须要知道的四类Equity

    许多人缠着我教他们打牌,开始几乎所有的问题都是问,你都玩什么牌. 这个话外行又很难解释,想来想去,我这样总结给他们(我也忘记自己过去有没有说过,我觉得总结的挺好的,只怕初学者听着又和天书一样了). 是 ...

  9. Tcpdump移植

    摘要: tcpdump对网络上的数据包进行截获的包分析工具. tcpdump可以将网络中传送的数据包的“头”完全截获下来提供分析.它支持针对网络层.协议.主机.网络或端口的过滤,并提供and.or.n ...

  10. [转帖]AMD第三代锐龙处理器首发评测:i9已无力招架

    AMD第三代锐龙处理器首发评测:i9已无力招架 Intel 从之前的 CCX 到了 CCD 增加了缓存 改善了 ccx 之间的延迟. https://baijiahao.baidu.com/s?id= ...