[Android] 怎么在应用中实现密码隐藏?

[Android] 怎么在应用中实现密码隐藏?

在安卓应用中,用户注册或者登录时,需要把密码隐藏,实现一定的保密效果。在安卓中,可以通过设置EditText组件的TransformationMethod来实现。

editText_password.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
editText_password.setTransformationMethod(PasswordTransformationMethod.getInstance());

HideReturnsTransformationMethod使密码在输入时将以明文显示,PasswordTransformationMethod将把密码变成一个个小黑点。

原文地址:https://www.cnblogs.com/guanghuiz/p/5228593.html