-
密码输入框的使用方法
- 在XML布局中添加EditText控件,使用EditText控件的属性进行限定 未限定代码:
- android:password值为true或者false,表示当前为输入密码框,即输入的字符是不可见的
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint = "请输入用户名"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:password="true"
android:hint="请输入密码"/>
-
限定代码:
- 有时候会对密码长度进行限制,或者对密码的输入类型进行限定
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLength="10"
android:numeric="integer"
android:password="true"
android:hint="请输入密码"/>
android:numeric表示对输入的类型进行限制
android:maxLength表示的输入的最长字符长度
-
注
- EditText还有许多的限定方式,例如maxLines等等,需要的可以自己查询一下