Android——网格布局仿计算器
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="6"
android:columnCount="4">
<TextView
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_columnSpan="4"
android:gravity="bottom|right"
android:background="#ccc"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="c"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="( )"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="÷"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="×"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="7"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="8"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="9"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="-"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="4"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="5"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="6"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="+"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="1"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="2"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="3"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="="
android:layout_columnWeight="1"
android:layout_rowSpan="2"
android:layout_rowWeight="1"
android:textSize="25sp"
android:layout_gravity="fill"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="0"
android:layout_columnWeight="1"
android:layout_columnSpan="2"
android:layout_rowWeight="1"
android:textSize="25sp"/>
<Button
android:layout_width="0dp"
android:layout_height="0dp"
android:text="."
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:textSize="25sp"/>
</GridLayout>
效果如图:

网格布局能够实现纵向和竖向合并
Android——网格布局仿计算器的更多相关文章
- Android 网格布局 计算器
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&quo ...
- Android 网格布局短信发送界面
<?xml version="1.0" encoding="utf-8"?> <GridLayout xmlns:android=" ...
- android的布局-----GridLayout(网格布局)
学习导图 (一)简介 网格布局由GridLayout所代表,在android4.0之后新增加的布局管理器,因此需要android4.0之后的版本中使用,如果在更早的平台使用该布局管理器,则需要导入相应 ...
- Android中帧布局-FrameLayout和网格布局-GridLayout
帧布局-FrameLayout 一.概念 帧布局中,容器为每个加入其中的空间创建一个空白的区域(成为一帧).每个空间占据一帧,这些帧会按gravity属性自动对齐. 帧布局的效果是将其中的所有空间叠加 ...
- android——学习:网格布局——GridLayout
Android一开始就提供了几种布局控件,如线性布局LinearLayout.相对布局RelativeLayout和表格布局TableLayout等,但在很多情况下,这些布局控件是不能满足要求的,因此 ...
- Android布局_网格布局GirdLayout
自Android4.0版本后新增的GirdLayout网格布局(API 14) <?xml version="1.0" encoding="utf-8"? ...
- Android精通:TableLayout布局,GridLayout网格布局,FrameLayout帧布局,AbsoluteLayout绝对布局,RelativeLayout相对布局
在Android中提供了几个常用布局: LinearLayout线性布局 RelativeLayout相对布局 FrameLayout帧布局 AbsoluteLayout绝对布局 TableLayou ...
- Android开发---网格布局案例
Android开发---网格布局案例 效果图: 1.MainActivity.java package com.example.android_activity; import android.ap ...
- Android RecyclerView网格布局
一个简单的网格布局activity_main.xml <?xml version="1.0" encoding="utf-8"?> <andr ...
随机推荐
- [USACO精选] 第一章 数值计算
好不容易坑来了传说中的USACO精选,近100题我要是能做完就哈哈哈哈了…继今天学并查集连番受挫之后,决定写一写基础题. #0 负二进制 2014-01-10 其实是想到就会做,不想到就不会做的题,数 ...
- Spring依赖关系
在Spring中,各个模块的依赖关系通过简单的IoC配置文件进行描述,使这些外部化的信息集中并且明了,我们在使用其他组件服务时,只需要去配置文件中了解和配置这些依赖关系即可,也就是说这里关心的是接口, ...
- IPAD2 5.1.1越狱后的屏幕不能自动旋转~~~
己顶,出现这问题的原因是因为越狱安装了插件的原因.问题解决了,大家没有遇到类似的问题吗?问题出在大家都装了一个SBSettings的插件,解决办法就是在这个插件的ISO 5+ Notification ...
- Hibernate缓存机制 (2013-07-02 13:51:32)转载▼
标签: java web hibernate 缓存 代码 分类: javaweb 缓存是位于应用程序与物理数据源之间,用于临时存放复制数据的内存区域,目的是为了减少应用程序对物理数据源访 ...
- 使用icon替换你的网页图标(转)
第一次使用 Font Awesome 发现相当的爽呀!它的图标很全,能够帮你节约时间去找图片.下面就来一起学习吧: 1: 去官方网站下载解压 http://fontawesome.io/ 2: 解压后 ...
- VMware Workstation 10.0.0.1295980 CN
从V10版本开始,VMware Workstation 官方自带简体中文了,以后大家不需要汉化啦! Winner of more than 50 industry awards, VMware Wor ...
- asp中cookie欺骗/注入原理与防范
一直以来sql注入被广泛关注,也有专门的防注系统代码.发现,如果代码不严谨也会有cookie欺骗/注入的情况.原来, 防注入系统没有注意到 Cookies 的问题!这里以ASP为例,分析一下cook ...
- Shell获取当前用户
id | sed -e 's/).*//g' -e 's/.*(//' 比$LOGNAME $NAME who am i都要准确一些
- hdu 2049
Ps:WA了无限次...简直做到崩溃..高中学的知识都忘了....这道题就是跟2048差不多.. 从N个人里选M个人,有Cmn种选法,然后就是M的错排*Cnm 代码: #include "s ...
- FineUI疑难杂症
1. 导出excel操作:因为fineui里的按钮自带异步功能,所以要把 EnableAjax="false" DisableControlBeforePostBack=" ...