0
私はedittextにdrawableの左と右のアイコンを追加しました。描画可能なパスワードを表示または非表示に使用することができますが、描画可能な右のアイコンをクリックすると描画可能な左が見えなくなります。この問題を解決するにはどうすればよいですか?引き出し可能な左のアイコンが見えなくなりますか?
txtPassword.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
final int DRAWABLE_RIGHT = 2;
if (event.getAction() == MotionEvent.ACTION_UP) {
if (event.getRawX() >= (txtPassword.getRight() - txtPassword.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
if (IsHidePwd) {
txtPassword.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_show_pwd, 0);
txtPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
IsHidePwd = false;
return true;
} else {
txtPassword.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_hide_pwd, 0);
txtPassword.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
IsHidePwd = true;
return true;
}
}
}
return false;
}
});
サイズをtxtPassword.setCompoundDrawablesWithIntrinsicBounds(10、10、R.drawable.ic_show_pwd、10)に指定しようとします。 それは私のために働く。 –