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学习笔记】系统类加载器

    可以通过“java.system.class.loader"属性指定系统类加载器 默认情况下,该属性值为空: public class Test { public static void m ...

  2. 【CodeForces - 707B】Bakery(思维水题)

    Bakery Descriptions 玛莎想在从1到n的n个城市中开一家自己的面包店,在其中一个城市烘焙松饼. 为了在她的面包房烘焙松饼,玛莎需要从一些储存的地方建立面粉供应.只有k个仓库,位于不同 ...

  3. kubeadm安装集群系列-5.其他操作

    常用的一些操作记录 imagePullSecrets kubectl -n [namespace] create secret docker-registry regsecret --docker-s ...

  4. python pip换源方法

    以下资料来源于网络: pip国内的一些镜像   阿里云 http://mirrors.aliyun.com/pypi/simple/   中国科技大学 https://pypi.mirrors.ust ...

  5. ZOJ Problem Set - 1009

    1.参考 http://blog.csdn.net/xiaogugood/article/details/17922105 这篇博客对算法介绍的很详细,我看这道题的时候,将题目理解出错,所以进入了一个 ...

  6. 2019牛客暑期多校训练营(第四场)- J free

    题目链接:https://ac.nowcoder.com/acm/contest/884/J 题意:给定一个无向图,有n个点,m条边(n,m<=1e3),起点S.终点T,在可以将k条边的权值变为 ...

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

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

  8. 用三台虚拟机搭建Hadoop全分布集群

    用三台虚拟机搭建Hadoop全分布集群 所有的软件都装在/home/software下 虚拟机系统:centos6.5 jdk版本:1.8.0_181 zookeeper版本:3.4.7 hadoop ...

  9. SafeArrayGetUBound(EveryPatientInfo.parray,1,&UBound);

    SafeArray在ADO编程中经常使用,它的主要目的是用于automation中的数组型参数的传递.因为在网络环境中,数组是不能直接传递的,而必须将其包装成Safe Array.实质上Safe Ar ...

  10. GCD and LCM HDU - 4497(质因数分解)

    Problem Description Given two positive integers G and L, could you tell me how many solutions of (x, ...