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 ...
随机推荐
- Android listview 制作表格样式+由下往上动画弹出效果实现
效果是这样的:点击按下弹出表格的按钮,会由下往上弹出右边的列表,按下返回按钮就由上往下退出界面. 布局文件: activity_main.xml <RelativeLayout xmlns:an ...
- 支持.NET和移动设备的XLS读写控件XLSReadWriteII下载地址及介绍
原文来自龙博方案网http://www.fanganwang.com/product/3085转载请注明出处 读写任何单元值 数字型.字符型.布尔型以及错误型.但是你了解日期和时间型单元吗?在Exce ...
- URL动态赋值
url动态赋值: 指的是url中包含{selector},即花括号括起来的jQuery选择器,当提交该url时,框架会自动将selector对应元素的值替换到花括号所占区域. (感觉实现了一点类似el ...
- centos ssh 无密码登录
在linux系统中,ssh是远程登录的默认工具,因为该工具的协议使用了RSA/DSA的加密算法.该工具做linux系统的远程管理是非常安全的.telnet,因为其不安全性,在linux系统中被搁置使用 ...
- SharePoint开发 - 自定义导航菜单(二)母版页的菜单应用
博客地址 http://blog.csdn.net/foxdave 接上篇点击打开链接 本篇叙述在母版页中应用之前的配置信息生成菜单,主要涉及到母版页的自定义,并应用了第三方控件库DevExpress ...
- iOS多线程之NSThread使用
iOS中的多线程技术 我们在iOS开发项目过程中,为了解决UI界面操作不被耗时操作阻塞,我们会使用到多线程技术.在iOS开发中,我们主要会用到三种多线程操作技术:NSThread,NSOperatio ...
- Mac下为我们开发的App制作gif动画演示(不仅仅针对开发者,想做gif图片的也可参考)
趁着工作不忙,就闲着倒腾自己的事情,把自己写的一个完整App<丁丁印记>整理了一番,总结其中用到的技术和实现的功能,并想把一些用到的技术分享给各位工友们,因为我自学iOS开发得益于大家的分 ...
- JVM-对象
1.对象的创建 当虚拟机遇到一条new指令时,首先去检查这个指令的参数是否能在常量池中定位到一个类的符号引用,并且检查这个符号引用代表的类是否已经被加载.解析和初始化.如果没有,那必须先执行相应的类加 ...
- ognl表达式root中取值顺序
不加#,先从栈顶取,如果没有(是没有这个属性而不是这个属性没有值),再往下取. 如果栈顶和非栈顶的对象拥有同一个属性名称,想直接取非栈顶的属性可以在ognl中用#root[i].属性名,可以取到属性的 ...
- hdu 2071
Ps:输出n个数里最大的 #include "stdio.h" int main(){ ],max; int i,j,n,t; while(~scanf("%d" ...