笔记链接: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. maven打包插件maven-shade-plugin简单介绍

    作用: 1.可以把依赖打入jar包,然后直接使用这个jar包,从而不用担心依赖问题 2.通过设置MainClass,创建一个可以执行的jar包 3.Java工程经常会遇到第三方 Jar 包冲突,使用 ...

  2. JButton点击事件

    JButton点击事件: 以前都是搞一个JFrame,放个JButton,然后用鼠标点击: 忽然之间: import javax.swing.JButton; public class Page06 ...

  3. centos 7 静态IP,指定DNS

    cd /etc/sysconfig/network-scripts/ 找到对应的网卡,配置并编辑 ls -l vim ifcfg-em1 配置例子: TYPE="Ethernet" ...

  4. C#.NET 如何打开高版本的sln文件

    我用VS2008去打开2010版本的解决方案,提示如下   其实我可以直接打开这个csproj文件并运行   关闭之后就会提示是否创建一个新的 sln文件

  5. vux 实现多栏滚动

    1.PopupPicker 组件 <!-- vux-ui --> <template> <div> <!-- 标题栏 --> <x-header ...

  6. 剑指Offer面试题29(java版):数组中出现次数超过一半的数字

    题目:数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字. 比如输入一个长度为9的数组{1,2,3,2.2,2.5,4,2}.因为数字2在数组中出现5次,超过数组长度的一半,因此输出2. 解 ...

  7. Keepalived+lvs 搭建高可用负载均衡

    本站点停止更新,请访问:blog.coocap.com 不了解负载均衡高可用的童鞋,强烈建议先看keepalived+nginx高可用负载均衡: 传送门(求粉):http://www.cnblogs. ...

  8. 10.06 WZZX Day1总结

    今天迎来了WZZX的模拟.打开pdf的时候我特别震惊,出题的竟然是神仙KCZ!没错,就是那个活跃于各大OJ,在各大OJ排名靠前(LOJ Rank1),NOI2018 Rank16进队的kczno1!! ...

  9. 编译Ruby2.0 问题解决

    compiling readline.creadline.c: In function ‘Init_readline’:readline.c:1886:26: error: ‘Function’ un ...

  10. hive 内部表与外部表的区别

    hive 内部表: hive> create table soyo55(name STRING,addr STRING,money STRING) row format delimited fi ...