android设置密码可见,android – 使用TextInputLayouts passwordToggleEnabled的可见密码

我正在使用TextInputLayout和支持库中的新函数:passwordToggleEnabled.这给了一个很好的“眼睛” – 图标,让用户可以打开和关闭密码可见性.

我的问题是,是否有办法使用此功能,但开始密码可见?

我的xml:

android:id="@+id/password"

android:layout_width="match_parent"

android:layout_height="wrap_content"

app:passwordToggleEnabled="true">

android:id="@+id/password_edit"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="@string/prompt_password"

android:inputType="textPassword" />

切换看起来与此类似:

我还没有找到一种方法在xml中执行此操作,而不是在呈现视图后手动切换可见性的方法.如果我将EditText的输入类型设置为textVisiblePassword,则不会显示切换.如果我在代码中使用例如mPasswordEditText.setTransformationMethod(null);显示密码但切换消失,用户无法再次隐藏密码.我知道我可以手动完成所有操作,但只是想知道我是否可以使用新的魔术切换工作

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值