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中,源码如下: /* ...
随机推荐
- Driver drowsy detection dataset
Introduction Driver drowsy detection dataset consists of both male and female drivers, with various ...
- Base64加密 解密
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- git学习教程二之远程仓库学习
首先你需要注册一个github用户名,我的github账户是:1654218052@qq.com 由于本地的git仓库和github的仓库是通过SSH加密的,所以我们还需要设置一点东西哦 第1步:创建 ...
- html5 iphone input 输入法 弹窗将页面顶起 解决办法
给 input 添加失焦事件,然后滚动视图 input.search(type="text",@blur="scrollTop") scrollTop(){ w ...
- svn clearup svn cleanup failed–previous operation has not finished; run cleanup if it was int错误的解决办法
今天svn提交,出现异常:svn cleanup failed–previous operation has not finished; run cleanup if it was interrupt ...
- HTML5元素周期表
HTML5元素周期表 根元素 1. html 文档根元素 元数据和脚本 1. head HTML文档中的第一个元素.包含文档元数据 2. title 文档标题 3. meta 文档的元数据. meta ...
- Hbase标准配置文件 + 增删改查
1.可用配置文件 <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href=&q ...
- Mac 每次重启终端后配置的不生效.需要重新source
Mac 每次都要执行source ~/.bash_profile 配置的环境变量才生效 自己在 ~/.bash_profile 中配置环境变量, 可是每次重启终端后配置的不生效.需要重新执行 : $s ...
- python之迭代器、可迭代对象、生成器、生成器对象、枚举类型
迭代器 # 迭代器:循环反馈的容器(集合类型)# -- 不同于索引取值,但也可以循环的从容器对象中从前往后逐个返回内部的值# 优点:不依赖索引,完成取值# 缺点:不能计算长度,不能指定位取值(只能从 ...
- Windows 下部署 hadoop spark环境
一.先在本地安装jdk 我这里安装的jdk1.8,具体的安装过程这里不作赘述 二.部署安装maven 下载maven安装包,并解压 设置环境变量,MAVEN_HOME=D:\SoftWare\Mave ...