笔记链接: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. ubuntu上跑python连接pg,报错 ImportError: No module named psycopg2

    ubuntu上跑python连接pg,报错  ImportError: No module named psycopg2 root@pgproxy1:~# python /home/zxw/PGWri ...

  2. 逆向碰到3des分析

    1.ios 某个app碰到涉及3des的解密函数. 2.底层调用的库函数. 3.对比CCCrypt的头文件 CCCryptorStatus CCCrypt( CCOperation op, /* kC ...

  3. Zend Studio如何调试?

    1.安装Zend Studio之前,本机已安装Apache2.如果使用Apache2作为服务器 Window-Preferences-Php-Php Servers 配置好 URL和Server Ro ...

  4. 使用-Wl直接向ld传递参数

    gcc -Wl, key1, value1, key2, value2, key3, value3 包括-Wl在内全部都是以逗号分隔. 上面等价于: ld key1=value1 key2=value ...

  5. ios19---xib

    // // ViewController.m #import "ViewController.h" @interface ViewController () @end @imple ...

  6. YTU 2622: B 虚拟继承(虚基类)-沙发床(改错题)

    2622: B 虚拟继承(虚基类)-沙发床(改错题) 时间限制: 1 Sec  内存限制: 128 MB 提交: 487  解决: 393 题目描述 有一种特殊的床,既能当床(Bed)用又能当沙发(S ...

  7. iOS 开发 公司开发者账号,在多台Mac上合作开发,共用一个账号和证书--图文详解

    参考 导出证书申请的MAC里的Xcode的开发者账号 .developerprofile 导出的开发者账号文件.developerprofile 导出PKCS12既是.p12文件 所拷贝的资料, .d ...

  8. 【Silverlight】Bing Maps学习系列(一):开发前的准备工作

    [Silverlight]Bing Maps学习系列(一):开发前的准备工作 微软推出的Bing Maps地图引擎,对外开放了Silverlight和Ajax两种客户端API,同时微软针对全球地图还推 ...

  9. Bing必应地图中国API一显示地图 (转) 做人要厚道

    Bing必应地图中国API一显示地图 2011-05-24 14:27:31|  分类: Bing&Google|字号 订阅     微软必应地图中国地图API发布已经有10天了,考虑到网上现 ...

  10. ZOJ 3956 Course Selection System 背包DP

    ZOJ3956 观察数据范围, c的值非常小 只有100 所以c的和也很有限 只有50000 是否可以从这里下手? 对于某一个c的和 我们一定希望h的和最大 才有可能是最终答案. 于是有了类似背包的d ...