Вам просто нужно вызвать эту функцию.
passwordTxtInputLayout = findViewById(R.id.text_input_layout_password);
etPassword = findViewById(R.id.login_password);
if (etPassword != null) {
etPassword.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
passwordTxtInputLayout.setEndIconVisible(true);
}
@Override
public void afterTextChanged(Editable s) {
}
});
и вызывать эту функцию всякий раз, когда длина пароля меньше и равна нулю
passwordTxtInputLayout.setEndIconVisible(false);
Убедитесь, что эта функция должна быть вызывается перед вызовом setError, иначе eyeIcon будет отключен.