title: android TextInputLayout changes EditText style after setting error to null
body: <p>for the first time I'm using the new Android's widget TextInputLayout, it's very nice but I'm facing some problem using setError method</p>
  
  <p>this is my xml </p>
  
  <pre><code>&lt;android.support.design.widget.TextInputLayout
      android:id="@+id/userData_txtNameWrapper"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:textColorHint="@color/light_gray"
      app:hintTextAppearance="@style/TextAppearence.App.TextInputLayout"&gt;
      &lt;EditText
          android:id="@+id/userData_txtName"
          style="@style/bold_textbox_style"
          android:layout_width="match_parent"
          android:layout_height="@dimen/textinut_height"
          android:layout_margin="5dp"
          android:hint="name"
          android:imeOptions="actionNext"
          android:inputType="text"
          android:paddingTop="10dp"
          android:textSize="@dimen/medium_text"/&gt;
  &lt;/android.support.design.widget.TextInputLayout&gt;
  </code></pre>
  
  <p><strong>WHAT IS HAPPENING:</strong></p>
  
  <p>when I run </p>
  
  <pre><code>setError("error message") 
  </code></pre>
  
  <p>the whole EditText background and hint text color becomes red and since here it's fine. The issue is when I run </p>
  
  <pre><code>setError(null) 
  </code></pre>
  
  <p>the EditText's style is completely changed from the original one.</p>
  
  <p><strong>STARTING SITUATION:</strong></p>
  
  <p>unfocused
  <a href="https://i.stack.imgur.com/zF6Uy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zF6Uy.png" alt="unfocused"></a>
  focused
  <a href="https://i.stack.imgur.com/5L1zQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5L1zQ.png" alt="focused"></a></p>
  
  <p><strong>AFTER</strong> <code>setError("mandatory field")</code></p>
  
  <p><a href="https://i.stack.imgur.com/zPpYU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zPpYU.png" alt="enter image description here"></a></p>
  
  <p><strong>AFTER</strong> <code>setError(null)</code></p>
  
  <p><a href="https://i.stack.imgur.com/eR4KM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/eR4KM.png" alt="enter image description here"></a></p>
  
  <p>I made a lot of researches but couldn't find anything helpful, what the hell should the problem be??</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Investigating in the android source code of <code>setError()</code> method I found this</p>
  
  <pre><code>public void setError(@Nullable CharSequence error) {
      if (!mErrorEnabled) {
          if (TextUtils.isEmpty(error)) {
              // If error isn't enabled, and the error is empty, just return
              return;
          }
          // Else, we'll assume that they want to enable the error functionality
          setErrorEnabled(true);
      }
      if (!TextUtils.isEmpty(error)) {
          ViewCompat.setAlpha(mErrorView, 0f);
          mErrorView.setText(error);
          ViewCompat.animate(mErrorView)
                  .alpha(1f)
                  .setDuration(ANIMATION_DURATION)
                  .setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR)
                  .setListener(new ViewPropertyAnimatorListenerAdapter() {
                      @Override
                      public void onAnimationStart(View view) {
                          view.setVisibility(VISIBLE);
                      }
                  })
                  .start();
          // Set the EditText's background tint to the error color
          mErrorShown = true;
          updateEditTextBackground();
          updateLabelVisibility(true);
      } else {
          if (mErrorView.getVisibility() == VISIBLE) {
              ViewCompat.animate(mErrorView)
                      .alpha(0f)
                      .setDuration(ANIMATION_DURATION)
                      .setInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR)
                      .setListener(new ViewPropertyAnimatorListenerAdapter() {
                          @Override
                          public void onAnimationEnd(View view) {
                              view.setVisibility(INVISIBLE);
                              updateLabelVisibility(true);
                          }
                      }).start();
              // Restore the 'original' tint, using colorControlNormal and colorControlActivated
              mErrorShown = false;
              updateEditTextBackground();
          }
      }
  
  
      private void updateEditTextBackground() {
          if (mErrorShown &amp;&amp; mErrorView != null) {
              // Set the EditText's background tint to the error color
              ViewCompat.setBackgroundTintList(mEditText,
                      ColorStateList.valueOf(mErrorView.getCurrentTextColor()));
          } else if (mCounterOverflowed &amp;&amp; mCounterView != null) {
              ViewCompat.setBackgroundTintList(mEditText,
                      ColorStateList.valueOf(mCounterView.getCurrentTextColor()));
          } else {
              final TintManager tintManager = TintManager.get(getContext());
              ViewCompat.setBackgroundTintList(mEditText,
                      tintManager.getTintList(R.drawable.abc_edit_text_material));
          }
      }
  </code></pre>
  
  <p>and debugging the code I found that the piece of code getting executed in <code>updateEditTextBackground()</code> is the following</p>
  
  <pre><code>final TintManager tintManager = TintManager.get(getContext());
  ViewCompat.setBackgroundTintList(mEditText,
          tintManager.getTintList(R.drawable.abc_edit_text_material));
  </code></pre>
  
  <p>It seem that android is arbitrary replacing the EditText's background tint. I tryed to create a file in my drawable folder named abc_edit_text_material.xml with this code </p>
  
  <pre><code>&lt;inset xmlns:android="http://schemas.android.com/apk/res/android"
         android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material"
         android:insetRight="@dimen/abc_edit_text_inset_horizontal_material"
         android:insetTop="@dimen/abc_edit_text_inset_top_material"
         android:insetBottom="@dimen/abc_edit_text_inset_bottom_material"&gt;
  
      &lt;selector&gt;
          &lt;item android:state_enabled="false" android:drawable="@color/white"/&gt;
          &lt;item android:state_pressed="false" android:state_focused="false" android:drawable="@color/white"/&gt;
          &lt;item android:drawable="@color/white"/&gt;
      &lt;/selector&gt;
  
  &lt;/inset&gt;
  </code></pre>
  
  <p>but this is the result after <code>setError(null)</code></p>
  
  <p><a href="https://i.stack.imgur.com/2L1ip.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2L1ip.png" alt="enter image description here"></a></p>
  
  <p>Moreover I noticed that the problem exists only when I run setError("error message") and then setError(null)</p>
  
  <p><strong>UPDATE 2</strong>
  This is the code I use to validate my inputs</p>
  
  <pre><code>public boolean validateInputs() {
      mTxtNameWrapper.setError(null);
      mTxtLastNameWrapper.setError(null);
      mTxtEmailWrapper.setError(null);
      mTxtCountryWrapper.setError(null);
      mTxtIdCardWrapper.setError(null);
      mTxtFiscalCodeWrapper.setError(null);
      mLblDocTypeError.setVisibility(View.GONE);
      if (Strings.isNullOrEmpty(mTxtName.getText().toString())) {
          mTxtNameWrapper.setError("Mandatory field");
          return false;
      }
      if (Strings.isNullOrEmpty(mTxtLastName.getText().toString())) {
          mTxtLastNameWrapper.setError("Mandatory field");
          return false;
      }
      if (Strings.isNullOrEmpty(mTxtEmail.getText().toString())) {
          mTxtEmailWrapper.setError("Mandatory field");
          return false;
      }
      if (!android.util.Patterns.EMAIL_ADDRESS.matcher(mTxtEmail.getText().toString()).matches()) {
          mTxtEmailWrapper.setError("Invalid email format");
          return false;
      }
      if (Strings.isNullOrEmpty(mTxtCountry.getText().toString())) {
          mTxtCountryWrapper.setError("Mandatory field");
          return false;
      }
      if (mRdgIdType.getCheckedRadioButtonId() == -1) {
          mLblDocTypeError.setText("Select a document type");
          mLblDocTypeError.setVisibility(View.VISIBLE);
          return false;
      }
      if (Strings.isNullOrEmpty(mTxtIdCard.getText().toString())) {
          mTxtIdCardWrapper.setError("Mandatory field");
          return false;
      }
      if (Strings.isNullOrEmpty(mTxtFiscalCode.getText().toString())) {
          mTxtFiscalCodeWrapper.setError("Mandatory field");
          return false;
      }
      return true;
  }
  </code></pre>
  
  <p>I'm going crazy!!!</p>