网格布局标签是GridLayout。这个布局是android4.0新增的布局。这个布局只有4.0之后的版本才能使用。

不过新增了一些东东

①跟LinearLayout(线性布局)一样,他可以设置容器中组件的对齐方式

②容器中的组件可以跨多行也可以跨多列(相比TableLayout直接放组件,占一行相比较)

因为是android 4.0新增的,API Level 14,在这个版本以前的sdk

都需要导入项目,等下会详细介绍

常用属性:

排列对齐:

①设置组件的排列方式:   android:orientation=""     vertical(竖直,默认)或者horizontal(水平)

②设置组件的对齐方式:   android:layout_gravity=""   center,left,right,buttom啊,这些,如果想同时用两种的话:eg: buttom|left

学习导图

(一)简介

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

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

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">

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

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"

/>

以上内容是小编给大家介绍的Android布局之GridLayout网格布局相关知识,希望大家喜欢。

android网格布局间距,Android布局之GridLayout网格布局相关推荐

  1. android网格布局间距,android – 删除回收站视图网格布局中的默认间距

    你必须利用保证金.不是填充物. StaggeredGridLayoutManager为每个网格项设置默认边距"30dp". 它可以改变如下, class StaggeredList ...

  2. 【Java AWT 图形界面编程】LayoutManager 布局管理器 ④ ( GridLayout 网格布局 | GridBagLayout 网格包布局 )

    文章目录 一.GridLayout 网格布局 二.GridLayout 构造函数 三.GridLayout 网格布局代码示例 四.GridBagLayout 网格包布局 一.GridLayout 网格 ...

  3. Android通知栏字体大小,Android通知栏介绍与适配总结(上篇)

    此文已由作者黎星授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 由于历史原因,Android在发布之初对通知栏Notification的设计相当简单,而如今面对各式各样的通知 ...

  4. Android 应用开发(50)---GridLayout(网格布局)

    GridLayout(网格布局) 今天要介绍的布局是Android 4.0以后引入的一个新的布局,和前面所学的TableLayout(表格布局) 有点类似,不过他有很多前者没有的东西,也更加好用, 可 ...

  5. Android 应用开发(39)---GridLayout(网格布局)

    GridLayout(网格布局) 可以自己设置布局中组件的排列方式 可以自定义网格布局有多少行,多少列 可以直接设置组件位于某行某列 可以设置组件横跨几行或者几列 另外,除了上述内容外,本节还会给大家 ...

  6. Android GridLayout网格布局实现复古小米计算器

    Android GridLayout网格布局实现复古小米计算器 闲暇时间整理一些Android基础知识 首先看效果图 首先是一些配色: <color name="btnColor&qu ...

  7. Android应用开发之GridLayout(网格布局)

    GridLayout 网格布局是Android 4.0以后引入的一个新的布局. 它和前面所学的TableLayout(表格布局) 有点类似,不过有很多前者没有的东西,也更加好用. 特点: 可以自己设置 ...

  8. Android UI -- 布局介绍(布局包括FrameLayout, LinearLayout, RelativeLayout, GridLayout)

    首先介绍常用布局类 FrameLayout 最简单的布局管理器. 这个布局管理类有几个特性: 添加组件默认在左上角的. 如果添加多个组件会叠加到一起,并且都在左上角.(可以通过一gravity属性改变 ...

  9. Android学习|布局——GridLayout 表格布局_(可行、列合并)

    Android学习|布局--GridLayout 表格布局 一.GridLayout 行.列 都可以进行合并 二.常见属性 三.子控件属性 四.Demo 1.常见属性Demo 2.子控件属性Demo ...

最新文章

  1. Oracle表空间文件损坏后的排查及解决
  2. C++,那些可爱的小陷阱(一)
  3. exfat驱动源码 linux_Linux 5.4内核正式发布:原生支持exFAT、AMD成最大赢家
  4. 支付宝的kill-ie
  5. Gearman的使用
  6. 存储系统管理服务器,Mainframe的存储管理系统和架构
  7. 从方法到实践!深度解读:企业数据治理到底治什么?怎么治?
  8. PowerDesigner中在生成的数据库脚本中用name列替换comment列作为字段描述的方法
  9. 2.IDA-数据显示窗口(反汇编窗口、函数窗口、十六进制窗口)
  10. moel vue 自定义v_vue在自定义组件中使用v-model的方法
  11. uml+oopc嵌入式c语言开发精讲_新的程序开发模式出现,传统的嵌入式C语言程序员快要灭绝了?...
  12. github访问慢解决办法
  13. JDBC操作数据库,第一:jsp插入mysql数据库,坎坷摸索分享
  14. 动易模板制作示例(三)
  15. RK3399外设驱动之MIPI
  16. signature=9b2caa13f2468eba05d2d57d9a88606d,【音响聚焦】顶级Hi-End音响发烧器材介绍(功放篇)...
  17. 计算机网络中rtd,一文了解Modern Standby与RTD3
  18. WiFi通信字节乱码问题的产生原因及解决方法
  19. iOS-长按识别二维码/生成二维码/扫描二维码
  20. 存储过程(SQL SERVER 2008)

热门文章

  1. windows生成ios上架截屏的方法
  2. Keil uVision添加新文件夹
  3. OpenCV实现频率域滤波——以高斯低通滤波去噪为例
  4. paper-修改要点
  5. 使用google Material 图标
  6. 全世界都可以放弃你,但是你不可以放弃你自己!
  7. 百度快照不更新怎么办,导致快照不更新的原因大全!
  8. STM32学习笔记(超详细整理144个问题)
  9. 远程安装无法退出电脑管家
  10. 腾讯千帆河洛上新日事清、微伴、新榜、腾讯企点、纷享销客、聚合数据、NPSMeter