1、相关属性

  GridLayout网格布局是4.0之后引入的布局方式!

    android:columnCount="4" //设置列数(4列)
android:rowCount="6" //设置行数(6行)
android:orientation="horizontal" //设置排列方式(默认竖直)
android:layout_gravity="fill" //设置对齐方式
android:layout_columnSpan="4" //横向横跨几列(4列)
android:layout_rowSpan="4" //纵向横跨几行(4行)
android:layout_row="2" //设置组件在第几行(第二行)
android:layout_column="2" //设置组件在第几列(第二列)

2、简单使用

  组件默认占一行一列

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:columnCount="4"
android:orientation="horizontal"
android:id="@+id/GirdLayout1"
android:rowCount="6"
tools:context="com.example.xianfengzhang.cleartext.GirdActivity"> <TextView
android:layout_columnSpan="4"
android:layout_gravity="fill"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:background="#ffcccc"
android:text="0"
android:gravity="right|bottom"
android:textSize="50sp"/>
<Button
android:layout_columnSpan="2"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:text="回退"/>
<Button
android:layout_columnSpan="2"
android:layout_height="wrap_content"
android:layout_gravity="fill_horizontal"
android:text="清空"/>
<Button android:text="+" /> <Button android:text="1" /> <Button android:text="2" /> <Button android:text="3" /> <Button android:text="-" /> <Button android:text="4" /> <Button android:text="5" /> <Button android:text="6" /> <Button android:text="*" /> <Button android:text="7" /> <Button android:text="8" /> <Button android:text="9" /> <Button android:text="/" /> <Button android:text="." /> <Button android:text="0" /> <Button android:text="=" /> </GridLayout>

效果图

Android之GridLayout网格布局的更多相关文章

  1. Android精通:TableLayout布局,GridLayout网格布局,FrameLayout帧布局,AbsoluteLayout绝对布局,RelativeLayout相对布局

    在Android中提供了几个常用布局: LinearLayout线性布局 RelativeLayout相对布局 FrameLayout帧布局 AbsoluteLayout绝对布局 TableLayou ...

  2. Android零基础入门第32节:新推出的GridLayout网格布局

    原文:Android零基础入门第32节:新推出的GridLayout网格布局 本期主要学习的是网格布局是Android 4.0新增的布局,和前面所学的TableLayout表格布局 有点类似,不过他有 ...

  3. android——学习:网格布局——GridLayout

    Android一开始就提供了几种布局控件,如线性布局LinearLayout.相对布局RelativeLayout和表格布局TableLayout等,但在很多情况下,这些布局控件是不能满足要求的,因此 ...

  4. android的布局-----GridLayout(网格布局)

    学习导图 (一)简介 网格布局由GridLayout所代表,在android4.0之后新增加的布局管理器,因此需要android4.0之后的版本中使用,如果在更早的平台使用该布局管理器,则需要导入相应 ...

  5. GridLayout(网格布局)

    常用属性: 排列对齐: ①设置组件的排列方式:  android:orientation=""     vertical(竖直,默认)或者horizontal(水平) ②设置组件的 ...

  6. GridLayout网格布局

    网格布局特点: l  使容器中的各组件呈M行×N列的网格状分布. l  网格每列宽度相同,等于容器的宽度除以网格的列数. l  网格每行高度相同,等于容器的高度除以网格的行数. l  各组件的排列方式 ...

  7. Android——gridLayout(网格布局)

    <?xml version="1.0" encoding="utf-8"?> <GridLayout xmlns:android=" ...

  8. java 图形化小工具Abstract Window Toolit ;布局管理器FlowLayout流式布局;BorderLayout边界布局;GridLayout网格布局;CardLayou重叠卡片布局;BoxLayout方框布局;绝对定位

    1.FlowLayout流式布局管理器: FlowLayout布局管理器中,组件像水流一样向某方向流动(排列),遇到障碍(边界)就折回,重头开始排列 .在默认情况下,FlowLayout局管理器从左向 ...

  9. 浅谈GridLayout(网格布局)

    Android 4.0 布局-->GridLayout 网格布局 以行列单元格的形式展示内部控件排列,可以实现类似计算机键盘效果 ,也可以实现可自动变行的标签群效果 使用GridLayout , ...

随机推荐

  1. 【POJ】1182 食物链

    这是<挑战设计程序竞赛>中的例题. 题目链接:http://poj.org/problem?id=1182 题意:中文题面.不赘述. 题解: 代码: //带权并查集 #include< ...

  2. 错误Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/fs/FSDataInputStream排查思路

    spark1(默认CDH自带版本)不存在这个问题,主要是升级了spark2(CDHparcel升级)版本安装后需要依赖到spark1的旧配置去读取hadoop集群的依赖包. 1./etc/spark2 ...

  3. OC和Cocos-js的互相调用

    OC调用cocos-js #import "ScriptingCore.h" #import "cocos2d.h" #include "script ...

  4. centos7使用iptables作为防火墙方法

    centos7使用iptables作为防火墙方法查看firewalld状态: systemctl status firewalld将centos7默认的firewalld停止,并将iptables作为 ...

  5. 【学术篇】SDOI2011 计算器

    好一道三合一...(然而被我做成了四合一) 其实1 2 3是独立的OvO 然后就可以逐个分析了... 1 快速幂..就不说了..(我省选的时候有这么水的20pts部分分么←_← 2 两种做法(写在标题 ...

  6. LightOJ 1342 Aladdin and the Magical Sticks 期望(结论题)

    题目传送门 题意:n根木棍,每根木棍都有一个权值,木棍有可识别的木棍和不可识别的木棍,每次抽取木棍时,会累加权值,如果是可识别的木棍就不放回,不可识别的木棍就放回,问每根木棍至少被抽取一次,权值的期望 ...

  7. pdfkit

    官方文档 0.准备 需要引入两个包,首先要npm install pdfkit安装pdfkit包 const PDF = require('pdfkit'); const fs = require(' ...

  8. C++: string copy-on-write

    https://blog.csdn.net/haoel/article/details/24058 https://www.cnblogs.com/promise6522/archive/2012/0 ...

  9. 区别 |峰度(Kurtosis)和偏度(Skewness)

      峰度(Kurtosis) 定义 峰度又称峰态系数,表征概率密度分布曲线在平均值处峰值高低的特征数,即是描述总体中所有取值分布形态陡缓程度的统计量.直观看来,峰度反映了峰部的尖度.这个统计量需要与正 ...

  10. thingkphp 路由实例

    我们已经了解了如何定义路由规则,下面我们来举个例子加深印象. 假设我们定义了News控制器如下(代码实现仅供参考): namespace Home\Controller; use Think\Cont ...