How to set TextInputLayout error message colour?

前端 未结 9 2224
旧巷少年郎
旧巷少年郎 2020-11-27 13:58

How can I change the colour of the error message that can be set to appear below the text field in a TextInputLayout (via setError(...) – see error

9条回答
  •  我在风中等你
    2020-11-27 14:33

    One side note. I have tried the accepted solution one with errorTextAppereance. It works really good but at first, the input underline color was not changing after applying a new errorTextAppereance style. I see there are a few comments and that other people are experiencing the same issue.

    In my case, this was happening when I was setting a new style after setting a new error text. Like this:

    passwordInputLayout.error = "Password strength"
    passwordInputLayout.setErrorTextAppearance(R.style.InputError_Purple)
    

    After switching the order of this two methods the text and underline color changes as expected.

    passwordInputLayout.setErrorTextAppearance(R.style.InputError_Purple)
    passwordInputLayout.error = "Password strength"
    

    And the error text appearance style looks something like this:

    
    

提交回复
热议问题