private boolean ishide=true;
if (ishide) {
//设置EditText文本为可见的
metpasswordlogin.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
} else {
//设置EditText文本为隐藏的
metpasswordlogin.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
ishide = !ishide;
metpasswordlogin.postInvalidate();
//切换后将EditText光标置于末尾
CharSequence charSequence = metpasswordlogin.getText();
if (charSequence instanceof Spannable) {
Spannable spanText = (Spannable) charSequence;
Selection.setSelection(spanText, charSequence.length());
}