[Android] 007_Activity控件布局_TableLayout

Android_007_Activity控件布局_TableLayout

TableLayout, 顾名思义, 就 “表格样式的布局”

在xml的布局文件中, 是以 <TableLayout></TableLayout> 为根标签.

然后以 <TableRow></TableRow>来定义每一行, 在这个标签里的所有控件都会在显示在同一行里.

简单的例子, 以”表格样式”分别显示三个”TextView”/”EditText”/”Button”

xml布局文件中的代码如下:

<? xml version="1.0" encoding="utf-8" ?>

< TableLayout xmlns:android ="http://schemas.android.com/apk/res/android"

android:layout_height
="wrap_content"

android:id
="@+id/tableLayout1"

android:layout_width
="match_parent" >

< TableRow

android:id ="@+id/tableRow1"

android:layout_width
="wrap_content"

android:layout_height
="wrap_content" >

< TextView

android:id ="@+id/TextView11"

android:text
="@string/TextView11"

android:textColor
="#ff0000"

/>

< TextView

android:id ="@+id/TextView12"

android:text
="@string/TextView12"

android:textColor
="#00ff00"

/>

< TextView

android:id ="@+id/TextView13"

android:text
="@string/TextView13"

android:textColor
="#ffffff"

/>

</ TableRow >

< TableRow

android:id ="@+id/tableRow2"

android:layout_width
="wrap_content"

android:layout_height
="wrap_content" >

< EditText

android:id ="@+id/EditText21"

android:background
="#ff0000"

/>

< EditText

android:id ="@+id/EditText22"

android:background
="#00ff00"

/>

< EditText

android:id ="@+id/EditText23"

android:background
="#ffffff"

/>

</ TableRow >

< TableRow

android:id ="@+id/tableRow3"

android:layout_width
="wrap_content"

android:layout_height
="wrap_content" >

< Button

android:id ="@+id/Button31"

android:text
="@string/Button31"

android:textColor
="#ff0000"

/>

< Button

android:id ="@+id/Button32"

android:text
="@string/Button32"

android:textColor
="#00ff00"

/>

< Button

android:id ="@+id/Button33"

android:text
="@string/Button33"

android:textColor
="#ffffff"

/>

</ TableRow >

</ TableLayout >

运行的结果如下图所示:

clip_image001[6]

转载于:https://www.cnblogs.com/shanhaiyang/archive/2011/07/10/2102656.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值