学习导图

(一)简介

  网格布局由GridLayout所代表,在android4.0之后新增加的布局管理器,因此需要android4.0之后的版本中使用,如果在更早的平台使用该布局管理器,则需要导入相应的支持库<android.support.v7.widget.GridLayout>

(二)案列----计算器

<?xml version="1.0" encoding="utf-8"?>
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="6"
android:columnCount="4"
android:layout_gravity="fill">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0"
android:textSize="80sp"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_columnSpan="4"
android:background="#eee"
android:padding="3sp"
android:editable="false"
android:textColor="#000"
/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_columnSpan="4"
android:text="清除"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="."
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="="
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
<Button
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:textColor="#000"
android:textSize="24dp"
android:layout_marginLeft="10dp"
android:background="@android:color/background_light"
/>
</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网格布局

    1.相关属性 GridLayout网格布局是4.0之后引入的布局方式! android:columnCount="4" //设置列数(4列) android:rowCount=&q ...

  4. GridLayout(网格布局)

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

  5. 鸿蒙的js开发部模式16:鸿蒙布局Grid网格布局的应用一

    鸿蒙入门指南,小白速来!从萌新到高手,怎样快速掌握鸿蒙开发?[课程入口]目录:1.Grid简介2.使用Grid布局实现的效果3.grid-row-gap和grid-colunm-gap属性4.< ...

  6. Android布局_网格布局GirdLayout

    自Android4.0版本后新增的GirdLayout网格布局(API 14) <?xml version="1.0" encoding="utf-8"? ...

  7. GridLayout网格布局

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

  8. 控件布局_FrameLayout(网格布局)

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=&qu ...

  9. css布局 弹性布局 和 网格布局

    这里就不写这两种布局的内容了 弹性布局链接:http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html 网格布局链接:https://www.ji ...

随机推荐

  1. 【PHP】判断变量是否为控

    1. isset功能:判断变量是否被初始化 说明:它并不会判断变量是否为空,并且可以用来判断数组中元素是否被定义过注意:当使用isset来判断数组元素是否被初始化过时,它的效率比array_key_e ...

  2. centos7安装phpstudy

    操作系统:CentOS 7 x86_64 SSH登录工具:FinalSHell 2.9.7 一.安装phpstudy 1.下载完整版: wget -c http://lamp.phpstudy.net ...

  3. python * args和** kwargs的用法

    所属网站分类: python基础 > 函数 作者:慧雅 链接: http://www.pythonheidong.com/blog/article/18/ 来源:python黑洞网 www.py ...

  4. docker 学习(2)

    docker容器中安装vim ubuntu 中默认未装vim,docker run ubuntu vim 出现: container_linux.go:247: starting container ...

  5. [BZOJ3312][USACO]不找零(状压DP)

    Description 约翰带着 N 头奶牛在超市买东西,现在他们正在排队付钱,排在第 i 个位置的奶牛需要支付 Ci元.今天说好所有东西都是约翰请客的,但直到付账的时候,约翰才意识到自己没带钱,身上 ...

  6. 将SpringBoot默认Json解析框架jackson替换成fastjson

    步骤一:引入依赖<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson< ...

  7. RNN教程之-2 LSTM实战

    前言 说出来你们不敢相信,刚才码了半天的字,一个侧滑妈的全没了,都怪这Mac的触摸板太敏感沃日.好吧,不浪费时间了,前言一般都是废话,这个教程要解决的是一个LSTM的实战问题,很多人问我RNN是啥,有 ...

  8. mybatis特殊字符处理

    在mybatis 的mapper.xml文件中特殊字符处理方式  仅供参考 出处:http://yaobenzhang.blog.163.com/blog/static/214395113201561 ...

  9. 浅谈javascript的运行机制

    积累一下这几天学的,记录一下: 一.为什么JavaScript是单线程? JavaScript语言的一大特点就是单线程,也就是说,同一个时间只能做一件事.那么,为什么JavaScript不能有多个线程 ...

  10. Cakephp在Controller中显示sql语句

    Cakephp在Controller中查询语句一般是: $this->Model->find(); 那么这条语句对应的sql语句是什么呢? 可以通过下面方法显示: 1. $dbo = Co ...