Android 4.0新组件:GridLayout详细说明
于Android 4.0(API 14)它提供了一个新的组件GridLayout,它继承自Linearlayout,用于执行网络格样式布局。
在某些方面,GridLayout与TableLayout和GridView有相似去处。于能够指定每个单元格“横跨”几个单元格或者“竖跨”几个单元格。这一点与html中<table>标签非常类似。
GridLayout的几个重要属性:
rowCount:行数
columnCount:列数
GridLayout的子View将能够应用属性:
layout_rowSpan:纵向跨几个单元格
layout_columnSpan:横向跨几个单元格
同一时候。GridLayout的子View能够不指定layout_width和layout_height(类似于TableLayout)
使用GridLayout能够非常方便的开发出类似计算器的页面。相比使用LinearLayout简化了代码、简化了嵌套层次、提高了性能,而且自适应性能更好。
示意图:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYm9va3MxOTU4/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" width="270" height="480" alt="">
布局代码:
<? xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:padding="8dp"
android:layout_width="match_parent"
android:layout_height="match_parent"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="计算器" /> <GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:rowCount="5"
android:columnCount="4"
android:layout_margin="4dp"> <Button android:text="C" /> <Button android:text="Del" /> <Button android:text="/" /> <Button android:text="x" /> <Button android:text="7" /> <Button android:text="8" /> <Button android:text="9" /> <Button android:text="-" /> <Button android:text="4" /> <Button android:text="5" /> <Button android:text="6" /> <Button android:text="+" /> <Button android:text="1" /> <Button android:text="2" /> <Button android:text="3" /> <Button
android:text="="
android:layout_gravity="fill"
android:layout_rowSpan="2" /> <Button
android:text="0"
android:layout_gravity="fill"
android:layout_columnSpan="2" /> <Button android:text="." /> </GridLayout>
</LinearLayout>
版权声明:本文博主原创文章。博客,未经同意不得转载。
Android 4.0新组件:GridLayout详细说明的更多相关文章
- android 5.0新特性
Android Lollipop 面向开发人员的主要功能 Material Design 设计 注重性能 通知 以大屏幕呈现 以文档为中心 连接性能再上一级 高性能图形 音频处理功能更强 摄像头和视频 ...
- android 7.0 新特性 和对开发者的影响
android 7.0新特性 - jiabailong的专栏 - 博客频道 - CSDN.NEThttp://blog.csdn.net/jiabailong/article/details/5241 ...
- Android 6.0 新特性 整理 资料来自网络
Android 6.0新特性 Runtime Permissions Doze and App Standby Apache HTTP Client Removal BoringSSL Access ...
- Android 5.0新控件——FloatingActionButton(悬浮按钮)
Android 5.0新控件--FloatingActionButton(悬浮按钮) FloatingActionButton是5.0以后的新控件,一个悬浮按钮,之所以叫做悬浮按钮,主要是因为自带阴影 ...
- Android 8.0 新特性
Android 8.0 (Android Oreo(奥利奥))新特性介绍 通知渠道 - Notification Channels 通知渠道是由应用自行定义的通知内容类别,借助渠道,开发者可以让用户对 ...
- Android Studio3.0 新特性 ~ New Features in Android Studio Preview (译文)
原文地址:https://developer.android.google.cn/studio/preview/features/index.html 最新Android Studio版本是Andro ...
- Android 6.0 新功能及主要 API 变更
运行时权限 这个版本中引入了新的权限模型,现在用户可以在运行时直接管理应用程序的权限.这个模型基于用户对权限控制的更多可见性,同时为应用程序的开发者提供更流畅的应用安装和自动升级.用户可以为已安装的每 ...
- Android 5.0 新特性
Material Design Material Design简介 Material Design是谷歌新的设计语言,谷歌希望寄由此来统一各种平台上的用户体验,Material Design的特点是干 ...
- Android 9.0新特性
1.全面屏支持,Android P加入了对刘海屏的支持,谷歌称之为凹口屏幕(display with a cutout).借助最新的提供的DisplayCutout类,开发者可以找到非功能区域的位置和 ...
随机推荐
- 14.4.7 Configuring the Number of Background InnoDB IO Threads 配置 后台InnoDB IO Threads的数量
14.4.7 Configuring the Number of Background InnoDB IO Threads 配置 后台InnoDB IO Threads的数量 InnoDB 使用bac ...
- ActiveX 暴漏你全部信息的可怕的插件!
近期在项目中常常接触ActiveX控件,对于这个名词相信仅仅要是上网看视频的用户一定都会遇到adobe更新或者载入的提示,这就是一个ActiveX控件.一直以为Active控件是处理复杂的页面逻辑提供 ...
- ThinkPHP多应用/项目配置技巧(使用同一配置文件)--(十六)
原文:ThinkPHP多应用/项目配置技巧(使用同一配置文件)--(十六) ThinkPHP多应用配置技巧(没有使用分组,这是通过入口文件产生的Home.Admin)----很实用! 比如:现在有Ho ...
- hdu 4970 Killing Monsters(数学题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4970 Problem Description Kingdom Rush is a popular TD ...
- struts2文件上传限制大小问题
struts2默认文件上传大小为2M,如需改动默认大小,解决方法例如以下: <struts> <constant name="struts.multipart.maxSiz ...
- hdu2389(HK算法)
传送门:Rain on your Parade 题意:t个单位时间后开始下雨,给你N个访客的位置(一维坐标平面内)和他的移动速度,再给M个雨伞的位置,问在下雨前最多有多少人能够拿到雨伞(两个人不共用一 ...
- FZU2181+poj2942(点双连通+判奇圈)
分析:我们对于那些相互不憎恨的人连边,将每次参加会议的所有人(不一定是全部人,只需人数>=3且为奇数)看做一个点双联通分量,那么每个点都至少有两个点与他相邻.即需要保证双联通分量中存在奇圈.至于 ...
- Java NIO的性能
最近调研了一下mina和netty框架的性能,主要是想了解java nio在单机能支持多少长连接. 首先,mina的qq群有同学反映说单机支持3w长连接是没问题的 其次,http://amix.dk/ ...
- Linux中下载,压缩,解压等命令
查看是否和还有一台Linux机器相通命令:ssh 主机名@Ip地址 ,提示输入password.就可以查看远程文件的文件夹 下载远程机器上的文件:scp 主机名@Ip地址:/path/s ...
- Android 布局之LinearLayout 子控件weight权重的作用详析(转)
关于Android开发中的LinearLayout子控件权重android:layout_weigh参数的作用,网上关于其用法有两种截然相反说法: 说法一:值越大,重要性越高,所占用的空间越大: 说法 ...