android下如何实现EditText显示隐藏密码的实现,

来源:互联网 发布:2017网络流行语翻译 编辑:程序博客网 时间:2024/06/05 20:19

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

参考:
http://stackoverflow.com/questions/39019675/remove-show-password-icon-in-android-n

0 0
原创粉丝点击