Android开发中TableLayout表格布局 一、引言 在移动端应用程序开发中,常常会使用到表格布局,iOS和Android开发框架中都提供了独立的表格视图控件供开发者使用,例如...iOS中的UITableView、UICollectionView,Android中的ListView、GridView等。...除了独立的视图控件外,Android中还提供了一个布局容器类TableLayout,使用其也可以进行方便的表格布局。 ...实际上,TableLayout就是采用这样的原理,TableLayout继承于LinearLayout,其中每个视图元素作为一行,同时Android中还提供了一个TableRow类,这个类同样继承自LinearLayout...三、关于TableLayout 在向TableLayout容器中添加或者移除视图的时候,开发者可以对其进行监听,示例如下: TableLayout tableLayout = new TableLayout
> android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com...android:text="tag" /> android.support.design.widget.TabItem android:layout_width...android.support.design.widget.TabItem android:layout_width="wrap_content" android...android:text="tag" /> android.support.design.widget.TabItem android:layout_width...android:text="tag" /> android.support.design.widget.TabItem android:layout_width
考虑到要对列整齐,方便布局,使用了TableLayout来进行布局。 ? 如图,Columns表示列数。ColumnWidth表示宽度百分比。Cells表示单元格集合。...可以使用ColSpan属性: Cell ColSpan="3">...如: TableLayout _tbAcreages = new TableLayout() { ID = "tbAcreages...TableLayout很好用,但是不能嵌套自己。不过可以套FormPanel。 ?...单选框组带个文本框小弟: Cell ColSpan="4">
通过本节课可以学习到的内容: RelativeLayout以及它的相关属性 TableLayout以及它的特有属性 ---- 实例代码: 运行效果参见本课程示例App:安卓猴Demos github...顾名思义,TableLayout布局就是表格布局。...TableLayout的特有属性 android:stretchColumns="1"设置所用行的第二列为扩展列,如果有三列的话,剩余空间由第二列补齐。.../ic_launcher" /> TableLayout android:layout_width="match_parent" android:layout_height...TableLayout> 下课 这一节课,我们学习了RelativeLayout和TableLayout的用法,其中前者是必须重点掌握的布局,后者是需要了解的布局
:text="Cell 1" /> <TextView android:text="Cell 2" /> <!...="8dp" android:background="#E0E0E0" /> <TextView android:text="Cell...android:text="Cell 3" android:padding="8dp" android:background="#E0E0E0" />...="8dp" android:background="#FFFFFF" /> <TextView android:text="Cell...android:text="Cell 6" android:padding="8dp" android:background="#FFFFFF" />
效果: 源码: TableLayout android:layout_height="wrap_content" xmlns:android="http://schemas.android.com.../apk/res/android" android:layout_width="wrap_content" android:shrinkColumns="1,2" android:stretchColumns...="1"> <Button android:text="按钮1" android:layout_height="wrap_content" android...android:text="按钮3" android:layout_height="wrap_content" android:layout_width...="wrap_content"> TableLayout> 通过
" Collapsible="true" runat="server" Title="表单信息" AutoHeight="true" LabelWidth="120"> TableLayout...>Cell> Cell ColSpan="2">Cell> Cell ColSpan="2"> TableLayout> ColSpan=\"2\">"); else _sbText.Append("Cell>"); //判断是否为数字
二、如何确定行数与列数 ①如果我们直接往TableLayout中添加组件的话,那么这个组件将占满一行!!! ②如果我们想一行上有多个组件的话,就要添加一个TableRow的容器,把组件都丢到里面!...多少列则是看tableRow中 的组件个数,组件最多的就是TableLayout的列数 三、重要属性 1、设置需要被隐藏的列:android:collapseColumns="此处填写隐藏列的索引值,多个则用逗号隔开..." 2、设置允许被收缩的列:android:shrinkColumns="此处填写被收缩列的索引值,多个则用逗号隔开" 3、设置运行被拉伸的列:android:stretchColumns="此处填写被拉伸列的索引值...,多个则用逗号隔开" 备注:如果是所有列都生效,则用"*"号即可 除了这三个常用属性,还有两个属性,分别就是跳格以及合并单元格,这和HTML中的Table类似: android:layout_column...="2":表示的就是跳过第二个,直接显示到第三个格子处,从1开始计算 android:layout_span="4":表示合并4个单元格,也就说这个组件占4个单元格
本文使用的控件有: RelativeLayout 相对布局 ScrollView 滚动视图 TableLayout 表格布局 ?...下面我们为ScrollView下添加一个TableLayout,这个一个表格布局控件,使得布局非常整齐。...TableLayout android:padding="3dip" android:id="@+id/tableLayout1" android:...="wrap_content"> TableLayout> TableLayout下可以有多行TableRow,每个TableRow里可以有多个子控件...,每个控件相当于一个cell(单元格)。
Android布局主要有以下几种: LinearLayout, RelativeLayout,TableLayout,AbsoluteLayout....="@id/ok" android:text="Cancel"/> (3) TableLayout 表格布局,类似于HTML的Table和Silverlight的Grid...通过TableRow来定义一行,如果一个控件占用多列可以设置android:layout_span,类似于HTML的colspan。...> TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="...="3dip" /> TableLayout> 这个表格有三列,通过设置android:stretchColumns="1"来增加了第二列的宽度。
Width="800" runat="server" Title="搜索条件" AutoHeight="true"> TableLayout...ID="TableLayout1" runat="server" Columns="3"> Cell>...> Cell> Cell> TableLayout>
setIcon(R.drawable.seek02)//设置图标 .setAdapter(new ArrayAdapter(mMainActivity,R.layout.cell...",Toast.LENGTH_SHORT).show(); return; } }); } } 附上 /layout/cell...tableLayout; public static void simple(View scource ){ tableLayout = (TableLayout) mMainActivity.getLayoutInflater...().inflate(R.layout.cell,null); AlertDialog.Builder builder = new AlertDialog.Builder(mMainActivity...布局: ---- 最后给出 MainActivity的布局文件: 可以看到 Button中 android:onClick="send"声明了 它的点击事件
TableLayout属性: android:collapseColumns:将TableLayout里面指定的列隐藏,若有多列需要隐藏,请用逗号将需要隐藏的列序号隔开。 ...-- 定义第一个表格,指定第2列允许收缩,第3列允许拉伸 --> 9 10 TableLayout 11 android:id="@+id/tablelayout01...-- 定义第2个表格,指定第2列隐藏 --> 51 52 TableLayout 53 android:id="@+id/tablelayout02" 54...-- 定义第3个表格,指定第2列填满空白--> 83 84 TableLayout 85 android:id="@+id/tablelayout03" 86...-- 定义第3个表格,指定第2列横跨2列--> 109 110 TableLayout 111 android:id="@+id/tablelayout04" 112
表格布局 GridLayout网格布局 ---- TableLayout表格布局 TableLayout表格布局.png TableLayout的介绍 TableLayout是将子类向分别排列成行和列的布局视图容器...collapseColumns隐藏列 效果如图: tablelayout android:collapseColumns = "0,2",用于隐藏第一列和第三列,代码如下: TableLayout...android:id="@+id/TableLayout" android:layout_width="match_parent" android:layout_height="wrap_content...="wrap_content" android:layout_height="wrap_content" android:text="five" /> TableLayout...,代码如下: tablelayout TableLayout android:id="@+id/TableLayout" android:layout_width="match_parent"
bodyStyle: "background:yellow", html: "未使用了fit布局,没有填充满" }) ] }); }); 7.TableLayout...TableLayout 7.2 代码 Ext.onReady(function() { var TableLayout = new Ext.Panel({ title: "TableLayout...{ html: "行1列2" }, { html: "行[1,2]列3", rowspan: 2, height: 180 }, { html: "行2列[1,2]", colspan...: 2, width: 266 } ], //将面板显示到HTML中: //TableLayout" style="width: 400px; float: left...; padding-left: 10px;"> renderTo: "TableLayout" }); });
在Android中提供了几个常用布局: LinearLayout线性布局 RelativeLayout相对布局 FrameLayout帧布局 AbsoluteLayout绝对布局 TableLayout...表格布局 GridLayout网格布局 TableLayout表格布局 TableLayout的介绍 TableLayout是将子类向分别排列成行和列的布局视图容器,TableLayout是由许多TableRow...collapseColumns隐藏列 效果如图: android:collapseColumns = "0,2",用于隐藏第一列和第三列,代码如下: TableLayout android:id...="@+id/TableLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android...: TableLayout android:id="@+id/TableLayout" android:layout_width="match_parent" android:layout_height
-- 定义第2个表格布局 ,指定第2列隐藏--> TableLayout android:layout_width="match_parent" android...-- 定义第3个表格布局,指定第2列和第3列可以被拉伸--> TableLayout android:layout_width="match_parent" android...android:text="拉伸的按钮" /> TableLayout> 上面页面中定义了 3个TableLayout...第1个TableLayout,指定第2列允许收缩,第3列允许拉伸。 第2个TableLayout,指定第2列被隐藏。 第3个TableLayout,指定第2列和第3列允许拉伸。...到此,TableLayout的示例结束,关于TableLayout的更多用法可以多动手练习。
Android 之 SMS 短信在Android系统中是保存在SQLite数据库中的,但不让其它程序访问(Android系统的安全机制) 现在我们在读取手机内的SMS短信,先保存在我们自己定义的SQLite...; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase...; import android.graphics.Color; import android.net.Uri; import android.os.Bundle; import android.util.Log...; import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TableRow.LayoutParams...(savedInstanceState); setContentView(R.layout.main); tableLayout = (TableLayout) findViewById(R.id.tableLayout
表格布局(Tablelayout) 简介: Tablelayout类以行和列的形式对控件进行管理,每一行为一个TableRow对象,或一个View控件。...:background="#7f00ffff"/> TableLayout android:id="@+id/table1" android:layout_width...-- 第2个TableLayout,用于描述表中单元格的属性,包括:android:layout_column 及android:layout_span--> <TextView...="wrap_content" android:textSize="15sp" android:background="#7f00ffff"/> TableLayout..." android:background="#7f00ffff"/> TableLayout android:id="@+id/table3"
表格布局管理器用TableLayout类表示,该类派生自LinearLayout类,所以TableLayout类也具有LinearLayout类的方法和属性。...在《从零开始学android编程之线性布局管理器》中提到的activity_linear.xml文件中使用表格布局管理器TableLayout,代码如下 <LinearLayout android...> TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content...:layout_height="wrap_content" android:text="第三行按键1" /> TableLayout> TableLayout android:layout_width="wrap_content" android:layout_height="wrap_content
领取专属 10元无门槛券
手把手带您无忧上云