当前位置: 移动技术网 > IT编程>移动开发>Android > Android中实现EditText密码显示隐藏的方法

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

2019年07月24日  | 移动技术网IT编程  | 我要评论

千秋霸业百战成功,宫浩文,海南考试网

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

这里写图片描述

<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”的时候在输入框的最右边就会显示眼睛一样的开关来显示和隐藏密码,需要的同学不妨试试看。

参考:

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网