如何解决使用密码切换显示或隐藏文本
我正在使用以下代码显示或隐藏密码
pwdLayout.setEndIconMode(TextInputLayout.END_ICON_PASSWORD_TOGGLE);
我能够实现显示或隐藏密码。 但是带有十字符号的眼睛图标显示密码,而没有十字符号的眼睛图标则隐藏密码。 我需要扭转这种逻辑该怎么做?
解决方法
从1.2.0
开始,这是默认行为:
如果要反转图标,可以使用类似以下内容的
:<com.google.android.material.textfield.TextInputLayout
app:endIconDrawable="@drawable/custom_password_eye"
具有:
<animated-selector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="NewApi">
<item
android:id="@+id/visible"
android:drawable="@drawable/design_ic_visibility"
android:state_checked="true"/>
<item
android:id="@+id/masked"
android:drawable="@drawable/design_ic_visibility_off"/>
<transition
android:drawable="@drawable/avd_show_password"
android:fromId="@id/masked"
android:toId="@id/visible"/>
<transition
android:drawable="@drawable/avd_hide_password"
android:fromId="@id/visible"
android:toId="@id/masked"/>
</animated-selector>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。