返回 Android...... 登陆

Android中实现EditText密码显示隐藏的方法

巴扎黑 2017-01-13 11:31:25 751

在Google发布了support:design:23+以后我们发现有这么一个东西TextInputLayout,先看下效果图:

2017010615271612.png

<android.support.design.widget.TextInputLayout
  android:id="@+id/pwdLayout"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  app:passwordToggleEnabled="true"
  >
  <EditText
  android:id="@+id/pwdEdt"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:hint="@string/edt_pwd_hint"
  android:maxLines="1"
  android:inputType="textPassword" />
 </android.support.design.widget.TextInputLayout>

只要在布局中添加属性app:passwordToggleEnabled=”true”就可以实现当EditText的inputType=”textPassword”的时候在输入框的最右边就会显示眼睛一样的开关来显示和隐藏密码,需要的同学不妨试试看。

更多关于Android中实现EditText密码显示隐藏的方法请关注PHP中文网(www.php.cn)其他文章!

最新手记推荐

• 用composer安装thinkphp框架的步骤 • 省市区接口说明 • 用thinkphp,后台新增栏目 • 管理员添加编辑删除 • 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消 回复 发送
  • PHP中文网