UI组件——GridLayout
来源:互联网 发布:网络导报张海亮 编辑:程序博客网 时间:2024/05/22 04:57
1 GridLayout(网格布局) 在Android4.0开始引入。
GridLayout可以把布局分为几行和几列。
GridLayout可以设置一个组件横框多少行,纵夸多少列。
GridLayout和TableLayout很相似,但是如果要设计行列布局,GridLayout使用更方便、更高效。因为:
GridLayout works with a flat-view hierarchy, where child views set their locations in the grid by specifying the rows and columns they should be in. By maintaining a flat hierarchy, GridLayout is able to more swiftly layout its child views.
The new GridLayout control for Android 4.0 is very powerful and we've just scratched the surface of what it can do
2 GridLayout常见属性
GridLayout常用的XML属性和方法说明
android:rowCount
setRowCount(int)
设置该网格的行数
android:columnCountsetColumnCount(int)设置该网格的列数量android:rowOrderPreserved
setRowOrderPreserved(boolean)
设置该网格容器是否保留行序号
android:columnOrderPreservedsetColumnOrderPreserved(boolean)设置该网格容器是否保留序列号android:useDefaultMarginssetUseDefaultMargins(boolean)设置该布局管理器是否使用默认的页边距GridLayout.LayoutParams常用的XML属性和方法说明
相关方法
略
略
略
略
略
android:orientation
略
说明:
(1) Gridlayout 的默认对齐方式是android:orientation="horizontal"。
<?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="2"
android:columnCount="2">
<TextView
android:text="Cell 0"
android:textSize="14dip" />
<TextView
android:text="Cell 1"
android:textSize="14dip" />
<TextView
android:text="Cell 2"
android:textSize="14dip" />
<TextView
android:text="Cell 3"
android:textSize="14dip" />
</GridLayout>
The layout will adjust the row and column sizes so that the cells can fit their content, as illustrated by the following diagram:
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="2"
android:columnCount="2"
android:orientation="vertical">
</GridLayout>
Now, the GridLayout will position the cells from top to bottom in each column, instead of left to right, as shown below:
(2) layout_gravity,android:layout_row , android:layout_column and layout_textSise等attribute can also adjust the size。
(3) layout_gravity attribute can also adjust the size。
<Button
android:layout_columnSpan="2"
android:text="0"/>
<Button
android:layout_columnSpan="3"
android:layout_gravity="fill"
android:text="="/>
Ref:
http://code.tutsplus.com/tutorials/android-user-interface-design-creating-a-numeric-keypad-with-gridlayout--mobile-8677
http://www.tuicool.com/articles/Rr2EfmA
0 0
- UI组件——GridLayout
- UI技巧 —— GridLayout & baseline
- GridLayout—网格布局
- UI组件——TextView
- GridLayout——android style
- Android UI(Layouts)-GridLayout 详解
- AngularJs的UI组件ui-Bootstrap——Datepicker Popup
- js玩具——UI组件:颜色
- js玩具——UI组件:规格
- js玩具——UI组件:位置
- js玩具——UI组件:边距
- 安卓第九天——UI组件
- Balloon.2.0 —— UI组件总览
- UI界面——自定义组件
- JQuery UI——滑动条组件
- JQuery UI——自动完成组件
- iOS开发——UI组件整理
- iOS开发——UI组件
- rank() over,dense_rank() over,row_number() ove的区别
- UML类图中箭头和线条的含义和用法
- hdu-5521-Meeting- 最短路-增点建图
- socket三次握手连接和四次断开连接
- 【UVa】495 - Fibonacci Freeze
- UI组件——GridLayout
- Windows平台下GCC编程之二维数组的转置
- poj 1936
- bzoj1069【SCOI2007】最大土地面积
- JSP JSTL标签用法
- 用一个数组实现两个栈
- Mac快捷键
- XCode7 无需开发者账号真机调试
- TCP/IP协议