代码设置edittext输入类型为密码类型

开发中常常会用到EditText输入框,要将他的输入类型设置为密码输入,但是直接在布局文件中设置时,hint字体风格就会不一样

所以我们在代码中设置: 


edittext.setTypeface(Typeface.DEFAULT);
edittext.setTransformationMethod(new PasswordTransformationMethod());
//明文显示密码
edittext.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
//隐藏密码
edittext.setTransformationMethod(PasswordTransformationMethod.getInstance());

猜你喜欢

转载自www.cnblogs.com/Sharley/p/9103713.html
今日推荐