对于一个用户友好的输入界面而言,接受用户输入的文本框内默认会提示用户如何输入;当前用户把焦点切换到输入框时,输入框自动选中其中已输入的内容,避免用户删除已有内容;当用户把焦点切换到只接受电话号码时,输入法自动切换到键盘
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:androrid="http://schemas.android.com/apk/res/android"
androrid:layout_width="match_parent"
androrid:layout_height="match_parent"
androrid:stretchColumns="1"
>
<TableRow>
<TextView
androrid:layout_width="match_parent"
androrid:layout_height="wrap_content"
androrid:text="用户名"
androrid:textSize="16sp"
/>
<EditText
androrid:layout_width="match_parent"
androrid:layout_height="wrap_content"
androrid:hint="请填写登录账号"
androrid:selectAllOnFocus="true"
/>
</TableRow>
<TableRow>
<TextView
androrid:layout_width="match_parent"
androrid:layout_height="wrap_content"
androrid:text="密码"
androrid:textSize="16sp"
/>
<!--只能接受数字密码-->
<EditText
androrid:layout_width="match_parent"
androrid:layout_height="wrap_content"
androrid:inputType="numberPassword"
/>
</TableRow>
<TableRow>
<TextView
androrid:layout_width="match_parent"
androrid:layout_height="wrap_content"
androrid:text="年龄"
androrid:textSize="16sp"
/>
<!--inputType="number"表明只能输入数值-->
<EditText
androrid:layout_width="match_parent"
androrid:layout_height="wrap_content"
androrid:inputType="number"
/>
</TableRow>
<TableRow>
<TextView
androrid:layout_width="match_parent"
androrid:layout_height="wrap_content"
androrid:text="生日"
androrid:textSize="16sp"
/>
<!--inputType="date"表明日期输入框-->
<EditText
androrid:layout_width="match_parent"
androrid:layout_height="wrap_content"
androrid:inputType="date"
/>
</TableRow>
<TableRow>
<TextView
androrid:layout_width="match_parent"
androrid:layout_height="wrap_content"
androrid:hint="请填写您的电话号码"
androrid:text="电话号码"
androrid:textSize="16sp"
/>
<!--inputType="phone"表明只能输入数值-->
<EditText
androrid:layout_width="match_parent"
androrid:layout_height="wrap_content"
androrid:selectAllOnFocus="true"
androrid:inputType="phone"
/>
</TableRow>
<Button
androrid:layout_width="wrap_content"
androrid:layout_height="wrap_content"
androrid:text="注册"
/>
</TableLayout>