吴裕雄--天生自然ANDROID开发学习:2.2.5 GridLayout(网格布局)

吴裕雄--天生自然ANDROID开发学习:2.2.5 GridLayout(网格布局),第1张

概述可以自己设置布局中组件的排列方式可以自定义网格布局有多少行,多少列可以直接设置组件位于某行某列可以设置组件横跨几行或者几列 实现代码:<GridLayoutxmlns:android="http://schemas.android.com/apkes/android"xmlns:tools="http://schemas.android.com/
可以自己设置布局中组件的排列方式可以自定义网格布局有多少行,多少列可以直接设置组件位于某行某列可以设置组件横跨几行或者几列

 

实现代码:<GrIDLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:tools="http://schemas.androID.com/tools"    androID:ID="@+ID/GrIDLayout1"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:columnCount="4"    androID:orIEntation="horizontal"    androID:rowCount="6" >    <TextVIEw        androID:layout_columnSpan="4"        androID:layout_gravity="fill"        androID:layout_marginleft="5dp"        androID:layout_marginRight="5dp"        androID:background="#FFCCCC"        androID:text="0"        androID:textSize="50sp" />    <button        androID:layout_columnSpan="2"        androID:layout_gravity="fill"        androID:text="回退" />    <button        androID:layout_columnSpan="2"        androID:layout_gravity="fill"        androID:text="清空" />    <button androID:text="+" />    <button androID:text="1" />    <button androID:text="2" />    <button androID:text="3" />    <button androID:text="-" />    <button androID:text="4" />    <button androID:text="5" />    <button androID:text="6" />    <button androID:text="*" />    <button androID:text="7" />    <button androID:text="8" />    <button androID:text="9" />    <button androID:text="/" />    <button        androID:layout_wIDth="wrap_content"        androID:text="." />    <button androID:text="0" />    <button androID:text="=" /></GrIDLayout> 
代码解析: 代码很简单,只是回退与清楚按钮横跨两列,而其他的都是直接添加的,默认每个组件都是 占一行一列,另外还有一点要注意的: 我们通过:androID:layout_rowspan与androID:layout_columnSpan设置了组件横跨 多行或者多列的话,如果你要让组件填满横越过的行或列的话,需要添加下面这个属性: androID:layout_gravity = "fill"!就像这个计算机显示数字的部分!3.用法归纳:①GrIDLayout使用虚细线将布局划分为行,列和单元格,同时也支持在行,列上进行交错排列 ②使用流程:step 1:先定义组件的对其方式 androID:orIEntation 水平或者竖直,设置多少行与多少列step 2:设置组件所在的行或者列,记得是从0开始算的,不设置默认每个组件占一行一列step 3:设置组件横跨几行或者几列;设置完毕后,需要在设置一个填充:androID:layout_gravity = "fill"
5.低版本sdk如何使用GrIDLayout:解决方法很简单:只需要导入v7包的grIDlayout包即可! v7包一般在sdk下的:sdk\extras\androID\support\v7\grIDlayout目录下 如果你没有的话,也可以到这里下载: grIDlayout_v7_jay.rar 但是用的时候,标签却是这样写的:<androID.support.v7.Widget.GrIDLayout>`
https://www.runoob.com/wp-content/uploads/2015/07/grIDlayout_v7_jay.rar

 

总结

以上是内存溢出为你收集整理的吴裕雄--天生自然ANDROID开发学习:2.2.5 GridLayout(网格布局)全部内容,希望文章能够帮你解决吴裕雄--天生自然ANDROID开发学习:2.2.5 GridLayout(网格布局)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1061419.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存