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. idea右键无run选项

    选中java 文件所在的package右键选中Mark Directory as---Sources  Root

  2. jmeter 实战

    JMeter 接口测试 什么是接口测试 概念 内部接口 方法与方法之间的交互 模块与模块之间的交互 一种调用对外包装的接口 Web接口分类 web接口分类:https.http.webService ...

  3. netty 文件传输

    FileServer package com.zhaowb.netty.ch13_1; import io.netty.bootstrap.ServerBootstrap; import io.net ...

  4. 转: PHP中this,self,parent的区别

    {一}PHP中this,self,parent的区别之一this篇 面向对象编程(OOP,Object OrientedProgramming)现已经成为编程人员的一项基本技能.利用OOP的思想进行P ...

  5. Swaks伪造邮件

    一.搭建邮件服务器 首先需要自己搭建邮件服务器采用的是EwoMail搭建参考链接: http://doc.ewomail.com/docs/ewomail/install 二.邮件伪造发送 swaks ...

  6. arm-linux-gcc 的使用

    1. 编译 C 文件,生成 elf 可执行文件 h1.c 源文件 #include <stdio.h> void hellofirst(void) { printf("The f ...

  7. 【luoguP3868】猜数字

    description 现有两组数字,每组k个,第一组中的数字分别为:a1,a2,...,ak表示,第二组中的数字分别用b1,b2,...,bk表示.其中第二组中的数字是两两互素的.求最小的非负整数n ...

  8. 最大流——poj1459

    #include<iostream> #include<cstdio> #include<cstring> #include<queue> using ...

  9. rancher2.0 自定义应用商店(catalog)

    1.进入自定义应用商店页面 ===================================================== ================================ ...

  10. go网络库cellent实现socket聊天功能

    一 .介绍 cellnet是一个组件化.高扩展性.高性能的开源服务器网络库 git地址:https://github.com/davyxu/cellnet 主要使用领域: 游戏服务器 方便定制私有协议 ...