我正在使用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);显示密码但切换消失,用户无法再次隐藏密码.我知道我可以手动完成所有操作,但只是想知道我是否可以使用新的魔术切换工作