笔记链接:http://www.cnblogs.com/igoslly/p/6799939.html

GirdLayout 计算器实例及详尽的笔记:http://www.cnblogs.com/skywang12345/p/3154150.html

网格布局:使容器中的各组件呈M行×N列的网格状分布。

和Relative Layout\Linear Layout相同,属于ViewGroup类型。

布局设置步骤

1、设置最大行、列值

android:columnCount=“5”
android:rowCount=“6”

2、设置数据输入顺序

android:orientation

3、设置行列权重

android:layout_columnWeight
android:layout_rowWeight

4、设置跨行、列格

android:layout_columnSpan="2"

示例:

篮球计分app,记录每一节比分表格

 <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:columnCount="6"
android:rowCount="3">
<TextView
android:text="Table"
style="@style/table_layout"/>
<TextView
android:text="1st"
style="@style/table_layout"/>
<TextView
android:text="2nd"
style="@style/table_layout"/>
<TextView
android:text="3rd"
style="@style/table_layout"/>
<TextView
android:text="4th"
style="@style/table_layout"/>
<TextView
android:text="TOTAL"
style="@style/table_layout"/>
<TextView
android:text="A"
style="@style/table_layout"/>
<TextView
android:text="0"
android:id="@+id/score_a_part1"
style="@style/table_layout"/>
<TextView
android:text="0"
android:id="@+id/score_a_part2"
style="@style/table_layout"/>
<TextView
android:text="0"
android:id="@+id/score_a_part3"
style="@style/table_layout"/>
<TextView
android:text="0"
android:id="@+id/score_a_part4"
style="@style/table_layout"/>
<TextView
android:text="0"
android:id="@+id/score_a_total"
style="@style/table_layout"/>
<TextView
android:text="B"
style="@style/table_layout"/>
<TextView
android:text="0"
android:id="@+id/score_b_part1"
style="@style/table_layout"/>
<TextView
android:text="0"
android:id="@+id/score_b_part2"
style="@style/table_layout"/>
<TextView
android:text="0"
android:id="@+id/score_b_part3"
style="@style/table_layout"/>
<TextView
android:text="0"
android:id="@+id/score_b_part4"
style="@style/table_layout"/>
<TextView
android:text="0"
android:id="@+id/score_b_total"
style="@style/table_layout"/>
</GridLayout>

显示效果:


申明:

1、本笔记为文字及图片均为个人原创,转载请注明博客园-igoslly

2、Android开发课程于2017年4年参与GoogleDeveloper进行学习,

Android开发笔记(3)——GridLayout的更多相关文章

  1. Android开发笔记:打包数据库

    对于数据比较多的控制一般会加入SQLite数据库进行数据存储,在打包时这些数据库是不自动打包到apk中的,如何创建数据库呢 方法1:将创建数据库的sql语句在SQLiteHelper继承类中实现,在第 ...

  2. Android开发笔记--hello world 和目录结构

    原文:Android开发笔记--hello world 和目录结构 每接触一个新东西 都有一个hello world的例子. 1.新建项目 2.配置AVD AVD 没有要新建个,如果不能创建 运行SD ...

  3. 【转】Android开发笔记(序)写在前面的目录

    原文:http://blog.csdn.net/aqi00/article/details/50012511 知识点分类 一方面写写自己走过的弯路掉进去的坑,避免以后再犯:另一方面希望通过分享自己的经 ...

  4. [APP] Android 开发笔记 003-使用Ant Release 打包与keystore加密说明

    接上节 [APP] Android 开发笔记 002 5. 使用ant release 打包 1)制作 密钥文件 release.keystore (*.keystore) keytool -genk ...

  5. [APP] Android 开发笔记 002-命令行创建默认项目结构说明

    接上节:[APP] Android 开发笔记 001 4. 默认项目结构说明: 这里我使用Sublime Text 进行加载.

  6. Android开发笔记——以Volley图片加载、缓存、请求及展示为例理解Volley架构设计

    Volley是由Google开源的.用于Android平台上的网络通信库.Volley通过优化Android的网络请求流程,形成了以Request-RequestQueue-Response为主线的网 ...

  7. Android开发笔记(一百三十四)协调布局CoordinatorLayout

    协调布局CoordinatorLayout Android自5.0之后对UI做了较大的提升.一个重大的改进是推出了MaterialDesign库,而该库的基础即为协调布局CoordinatorLayo ...

  8. 【转】Android开发笔记——圆角和边框们

    原文地址:http://blog.xianqu.org/2012/04/android-borders-and-radius-corners/ Android开发笔记——圆角和边框们 在做Androi ...

  9. 《ArcGIS Runtime SDK for Android开发笔记》

    开发笔记之基础教程 ArcGIS Runtime SDK for Android 各版本下载地址 <ArcGIS Runtime SDK for Android开发笔记>——(1).And ...

  10. 《ArcGIS Runtime SDK for Android开发笔记》——离在线一体化技术:概述

    1.前言 数据生产和数据展示是常见的两大专业级移动GIS应用场景,这里我们针对数据生产环节的ArcGIS的离在线一体化技术给大家做一个基本的介绍和梳理. 使用ArcGIS离在线一体化技术首先需要以下基 ...

随机推荐

  1. CSS3的animation功能

    旋转动画 <img src="https://facebook.github.io/react/img/logo.svg" class="App-logo" ...

  2. 【转】配置windows路由表,使电脑同时连接内网外网方法

    1. 公司内部,内网和外网的网关不一样,怎么样让电脑可以同时上内网和外网呢? 来一张不相关的磁盘结构图: ----------------------------------------------- ...

  3. CentOS command

    管理centos服务器的时候常会对文件进行一些常规操作,除了ftp之外了解在ssh下必要的文件操作命令那也是必不可少的,以下摘录一些常用的文件操作命令: 文件操作: ls ####查看目录中的文件## ...

  4. cout 堆栈,operator&lt;&lt; 运算符重载输出问题

    在C++中cout的输出流其中,有一些问题非常easy出错,就比方以下这道简单程序.看似简单.但却是一个值得深思的问题~~ #include <iostream> using namesp ...

  5. C中多线程开发

    1 引言  线程(thread)技术早在60年代就被提出,但真正应用多线程到操作系统中去,是在80年代中期.solaris是这方面的佼佼者.传统的 Unix也支持线程的概念,可是在一个进程(proce ...

  6. hdu, KMP algorithm, linear string search algorithm, a nice reference provided

    reference: Rabin-Karp and Knuth-Morris-Pratt Algorithms By TheLlama– TopCoder Member https://www.top ...

  7. 扩展gcd求解二元不定方程及其证明

    #include <cstdio> #include <iostream> using namespace std; /*扩展gcd证明 由于当d = gcd(a,b)时: d ...

  8. ZOJ 3870 Team Formation 贪心二进制

                                                    B - Team Formation Description For an upcoming progr ...

  9. Android合并两个APP的详细做法(掌握)

    有时候因公司需求,要求合并两个APP 使用里面的功能. 平台:Studio 小白鼠:二维码扫描 和自己项目 详细步骤: /**  * 1.将解压后的android/assets目录复制到项目中的mai ...

  10. ios24--改变button的文字和图片

    // // ViewController.m // 09-UIButton内部子控件的调整 // // Created by xiaomage on 15/12/30. // Copyright © ...