Android 计算器制作 1.布局
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.布局的更多相关文章
- Android 计算器制作 2.注册View 构建函数
鄙人新手 整了 快两天 终于搞定了.. 1.首先是MainActivity 中 在Oncreate函数中 注册 2.按+ 或者 - 号 来分成两大字符串 s1 和 s2 再将s2 分为更小的s1 和 ...
- Android计算器布局
Android(安桌)计算器布局实现 ——解决整个屏幕方案 引言: 学完了android布局的几种方式,做了一个android计算器. 我在网上搜索了这方面的资料,发现了布局都 ...
- Flexbox制作CSS布局实现水平垂直居中
Flexbox实现一个div元素在body页面中水平垂直居中: <!DOCTYPE html><html lang="en"><head> & ...
- Android中制作自定义dialog对话框的实例
http://www.jb51.net/article/83319.htm 这篇文章主要介绍了Android中制作自定义dialog对话框的实例分享,安卓自带的Dialog显然不够用,因而我们要继 ...
- Android计算器简单逻辑实现
Android计算器简单逻辑实现 引言: 我的android计算器的实现方式是:按钮输入一次,就处理一次. 但是如果你学过数据结构(栈),就可以使用表达式解析(前缀,后缀)处理. 而这个方式已经很成熟 ...
- Android模板制作
本文详细介绍模板相关的知识和如何制作Android模版及使用,便于较少不必要的重复性工作.比如我在工作中如果要创建一个新的模块,就不要需要创建MVP相关的几个类:Model.View.Presente ...
- Android中的LinearLayout布局
LinearLayout : 线性布局 在一般情况下,当有很多控件需要在一个界面列出来时,我们就可以使用线性布局(LinearLayout)了, 线性布局是按照垂直方向(vertical)或水平方向 ...
- Android开发-之五大布局
在html中大家都知道布局是什么意思了,简单来说就是将页面划分模块,比如html中的div.table等.那么Android中也是这样的.Android五大布局让界面更加美化,开发起来也更加方便.当然 ...
- 简单研究Android View绘制三 布局过程
2015-07-28 17:29:19 这一篇主要看看布局过程 一.布局过程肯定要不可避免的涉及到layout()和onLayout()方法,这两个方法都是定义在View.java中,源码如下: /* ...
随机推荐
- (转载)PIM-SM协议初探(一)路由角色选举
PIM是Protocol Independent Multicast(协议无关组播)的简称,表示可以利用静态路由或者任意单播路由协议(包括RIP.OSPF.IS-IS.BGP等)所生成的单播路由表为I ...
- Tanimoto Coefficient
Tanimoto Coefficient The Tanimoto coefficient between two points, a and b, with k dimensions is calc ...
- nexus私服库被误删如何恢复
恢复步骤: 1,登录nexus服务器,找到nexus安装目录(默认/usr/local/下): 2,找到sonatype-work/nexus/trash 下找到你删除的库: 3,copy到指定的so ...
- ETH挖矿
转载声明:http://www.120btc.com/baike/coin/1021.html (仅为了方便自己及原文章被删除) 最近以太坊大涨市值成为仅次比特币的第二大数字货币,那么以太坊(ETH) ...
- VMware Workstation 12许可证
VMware 12专业版永久许可证密钥: 5A02H-AU243-TZJ49-GTC7K-3C61N VF5XA-FNDDJ-085GZ-4NXZ9-N20E6 UC5MR-8NE16-H81WY-R ...
- 抄录的Linux命令
daemon daemon 有一个很高大上的中文名字,叫 守护进程 . 有句话是这么说的,如果 Unix 中没有了守护进程,那么 Unix 就不会是相同的. 它很有个性,是一个运行在后台且不受终端控制 ...
- C#ModBus Tcp
C#ModBus Tcp 报文解析 上一篇博客已经完成 C#ModBus Tcp Master的实现 本篇主要对不同的功能码所发出的报文进行解析(包括请求报文及响应报文) 读操作 功能码 0x01 ...
- Android性能专项分类
性能专项分类:1.资源消耗2.启动耗时3.主要页面加载时间4.内存泄漏.抖动5.卡顿.页面渲染 一.资源消耗:CPU.内存.流量.功耗-----1.查看CPU占用率:adb shell dumpsys ...
- hdoj6446(树形DP)
题目链接:https://vjudge.net/problem/HDU-6446 题意:简化题意后就是求距离和的2*(n-1)!倍. 思路: 简单的树形dp,通过求每条边的贡献计算距离和,边(u,v) ...
- (转)新手入局 你必须要知道的四类Equity
许多人缠着我教他们打牌,开始几乎所有的问题都是问,你都玩什么牌. 这个话外行又很难解释,想来想去,我这样总结给他们(我也忘记自己过去有没有说过,我觉得总结的挺好的,只怕初学者听着又和天书一样了). 是 ...