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. php支持多个地址跨域访问

    //跨域访问的时候才会存在此字段 $origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : ''; $allow_ori ...

  2. vue如何获取并操作DOM元素

    原文地址 方法一: 直接给相应的元素加id,然后再document.getElementById("id");获取,然后设置相应属性或样式 方法二: 使用ref,给相应的元素加re ...

  3. Django:(05)类视图,装饰器和中间件

    一.类视图的定义和使用 在Django中还可以通过类来定义一个视图,称为类视图. 定义一个类视图:定义一个类,需继承 Django 提供的 View 类 . from django.views.gen ...

  4. 使用国内镜像给ROS安装提速

    大半年没写博客了.最近有幸参与机器人导航研究,在学习ROS相关知识.在安装ROS时使用国外的官方源安装非常慢.这里把使用国内镜像的安装方式做一个记录. 笔者用的是Kinetic版本,操作系统是Ubun ...

  5. HDU 4417 【线段树+离线处理】

    http://acm.hdu.edu.cn/showproblem.php?pid=4417 题意:找出给定区间内,有多少个数小于等于给定的数.用线段树维护的话会超时,要用到线段树的离线操作,对询问与 ...

  6. 2019牛客暑期多校训练营(第八场)-A All-one Matrices (单调栈+前缀和)

    题目链接:https://ac.nowcoder.com/acm/contest/888/A 题意:给n×m的01矩阵,求出其中全为1的矩阵个数(不被其它全1矩阵包括). 思路:和第二场多校的次大子矩 ...

  7. Vue:不同页面之间的传递参数(二)---query

    1) 在router文件下的index.js中,添加相关路径 routes: [ { path: '/', name: 'Hello', component: HelloWorld }, { path ...

  8. Count Different Palindromic Subsequences

    Given a string S, find the number of different non-empty palindromic subsequences in S, and return t ...

  9. GridControl gridView显示筛选行,设置条件为包含

    public static void SetFilter(GridView gdv) {     gdv.OptionsView.ShowAutoFilterRow = true; //设置筛选行  ...

  10. vue中关于checkbox数据绑定v-model指令说明

    vue.js为开发者提供了很多便利的指令,其中v-model用于表单的数据绑定很常见, 下面是最常见的例子: <div id='myApp'> <input type="c ...