1 需求

  • 平均分配空间

XML attributes

  • https://developer.android.google.cn/reference/android/R.attr

2 接口

public class GridLayout extends ViewGroup

java.lang.Object

android.view.View

android.view.ViewGroup

android.widget.GridLayout

XML attributes

  • android:columnCount
  • android:orientation
  • android:rowCount

3 示例

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:columnCount="4"android:orientation="horizontal"android:rowCount="6"tools:context=".MainActivity"><EditTextandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnSpan="4"android:layout_columnWeight="1" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnSpan="3"android:layout_columnWeight="1"android:text="0" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="+" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="1" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="2" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="3" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="-" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="4" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="5" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="6" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="*" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="7" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="8" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="9" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="/" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="Delete"android:textAllCaps="false" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_columnWeight="1"android:text="Clear"android:textAllCaps="false" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_row="5"android:layout_column="2"android:layout_columnWeight="1"android:text="=" /><Buttonandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_row="5"android:layout_column="3"android:layout_columnWeight="1"android:text="%" /></GridLayout>


4 参考资料

Android 六大布局之 GridLayout(网格布局)_蚩尤后裔的博客-CSDN博客_gridlayout

(Android学习)GridLayout平均分配空间_小白不止如此的博客-CSDN博客_gridlayout 平均

GridLayout平均分配空间_最爱吃葡萄的博客-CSDN博客_gridlayout 平分

Android技能树-GUI-布局-GridLayout类相关推荐

  1. Android 界面滑动实现---Scroller类 从源码和开发文档中学习(让你的布局动起来)...

    在android学习中,动作交互是软件中重要的一部分,其中的Scroller就是提供了拖动效果的类,在网上,比如说一些Launcher实现滑屏都可以通过这个类去实现..   例子相关博文:Androi ...

  2. android功能网格布局,Android布局总结一:GridLayout布局(网格布局)

    GridLayout布局简介 GridLayout布局是Android4.0(API Level 14)新引入的网格矩阵形式的布局控件. GridLayout属性介绍 本身属性 android:ali ...

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

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

  4. android使用桢布局,Android 常用布局

    Android的布局有: LinearLayout线性布局 RelativeLayout            相对布局 FrameLayout单桢布局 TableLayout表格布局 GridLay ...

  5. 以下哪些属于android控件的touch事件?_聊聊 Android 的 GUI 系统

    你长得辣么好看,我想着要更详细地了解你.今天,让我们一起来聊聊 Android 的 GUI 系统. 缘起 在2019年的 Google I/O 大会上,Jetpack 团队首次为大家介绍了 Jetpa ...

  6. 聊聊 Android 的 GUI 系统

    你长得辣么好看,我想着要更详细地了解你.今天,让我们一起来聊聊 Android 的 GUI 系统. 缘起 在2019年的 Google I/O 大会上,Jetpack 团队首次为大家介绍了 Jetpa ...

  7. Android六大基本布局详解

    一.基本理论 Android六大基本布局分别是:线性布局LinearLayout.表格布局TableLayout.相对布局RelativeLayout. 层布局FrameLayout.绝对布局Abso ...

  8. android中自适应布局教程,Android自适应布局设计技巧

    由于目前在做的一款app需要适配手机和平板,所以我在研究怎么构建可适应所有屏幕尺寸的布局方法. 在web的自适应布局上我有很多经验,比如使用网格流,CSS3中的media queries属性等等,这些 ...

  9. android封装好的Color类中的常量

    通过android封装好的Color类中的常量 public static final int BLACK = 0xFF000000; public static final int DKGRAY = ...

最新文章

  1. 厦大计算机学硕考研复试,【图片】一战厦大计算机上岸,经验帖。慢更【考研吧】_百度贴吧...
  2. 启动php服务命令,启动|停止服务
  3. 【技术干货】浅析State-Thread
  4. VTK:vtkTupleInterpolator 插值用法实战
  5. flutter图片点击跳转_使用Flutter之后,我们的CPU占用率降了50%
  6. 狂神说学习笔记 Java流程控制
  7. 线程池的submit和execute方法区别
  8. Oracle树反向查询的优化(转载)
  9. apache server和tomcat集群配置一:水平负载
  10. 九型人格,工作中的好帮手
  11. installanywhere打包过程(openproj版)
  12. STM32串口通信实例
  13. 回顾2020年(1)
  14. AR.js摄像头前置的问题(已解决)(H5调用摄像头)
  15. BOOTCAMP U盘安装WIN7一直显示无法创建可引导的USB驱动器
  16. javax.persistence.EntityNotFoundException: Unable to find报错
  17. VC程序里判断系统是64位还是32位的正确方法
  18. 01改变世界:机械之美——机械时期的计算设备
  19. JAVA基于NIO客户端对客户端简单聊天DEMO(服务器转发消息)
  20. python 二维强度图_Python简单做二维统计图

热门文章

  1. git 无法push远程仓库 Note about fast-forwards 问题解决
  2. debian服务器系统安装,ikoula独立服务器dd安装debian8系统
  3. 广东小鹏汽车产业控股公司增资至15亿,增幅达103.25%
  4. MySQL Workbench main_menu.xml 文件 可直接粘贴(上)
  5. C语言编译器哪个好_6款好用的C语言编译器推荐
  6. C语言学生管理系统(将数据保存至TXT文档)附源码
  7. RubyMine2016.3自动补全默认第一个选项配置
  8. 浅析传统防火墙存在的五大不足之处(转)
  9. python-(5-3)内置函数-zip locals globals sorted filter map
  10. Linux常用命令_top