Android ApiDemos示例解析(165):Views->Layouts->TableLayout->10. Simple Form

本文介绍如何使用TableLayout在Android中构建一个简单的输入表单,包括文本输入框和按钮组件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前面介绍了使用LinerLayout和RelativeLayout构造Simple Form:

Android ApiDemos示例解析(145):Views->Layouts->LinearLayout->5.Simple Form

Android ApiDemos示例解析(152):Views->Layouts->RelativeLayout->2.Simple Form

本例使用LabelLayout构造了一个简单输入表单:

<TableLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:stretchColumns=”1″>

<TableRow>
<TextView
android:text=”@string/table_layout_10_user”
android:textStyle=”bold”
android:gravity=”right”
android:padding=”3dip” />

<EditText android:id=”@+id/username”
android:text=”@string/table_layout_10_username_text”
android:padding=”3dip”
android:scrollHorizontally=”true” />
</TableRow>

<TableRow>
<TextView
android:text=”@string/table_layout_10_password”
android:textStyle=”bold”
android:gravity=”right”
android:padding=”3dip” />

<EditText android:id=”@+id/password”
android:text=”@string/table_layout_10_password_text”
android:password=”true”
android:padding=”3dip”
android:scrollHorizontally=”true” />
</TableRow>

<TableRow
android:gravity=”right”>

<Button android:id=”@+id/cancel”
android:text=”@string/table_layout_10_cancel” />

<Button android:id=”@+id/login”
android:text=”@string/table_layout_10_login” />
</TableRow>
</TableLayout>

android:stretchColumns=”1″ 表示第二列将占据表格剩余空间,注意EditText 的android:scrollHorizontally 属性,当EditText输入多行时,该行高度也会跟着变化:

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值