ivPasswordIsShow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ivPasswordIsShow.isSelected()) { ivPasswordIsShow.setSelected(false); edit_upwd.setTransformationMethod(PasswordTransformationMethod.getInstance());//设置可见 edit_upwd.setSelection(edit_upwd.getText().toString().length()); } else { ivPasswordIsShow.setSelected(true); edit_upwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());//设置不可见 edit_upwd.setSelection(edit_upwd.getText().toString().length()); } } });
EditText作为密码框,点击可见不可见按钮,实现密码的可见和不可见
最新推荐文章于 2022-08-09 14:52:18 发布