Android中实现EditText密码显示隐藏的方法
程序员文章站
2024-02-23 20:32:04
在google发布了support:design:23+以后我们发现有这么一个东西textinputlayout,先看下效果图:
在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”
的时候在输入框的最右边就会显示眼睛一样的开关来显示和隐藏密码,需要的同学不妨试试看。
参考:
上一篇: 详解JS与APP原生控件交互
下一篇: 微服务异常太乱,我们如何分类?