public void afterTextChanged(Editable s) { if (textInputLayout.getEditText().getText().toString().length() != length) { textInputLayout.setError(errorInfo); textInputLayout.setErrorEnabled(true); } else { textInputLayout.setError(null);//必须要添加否则出现空白不隐藏的问题 textInputLayout.setErrorEnabled(false); } }