Is is possible to set error on Text Input Layout without showing any error message (i'm already doing it in another place)?.
textinputlayout.setError("");
won't work unfortunately.
What i basically need is the textInputLayout to change its line color to red, but i need to do it programmatically. Thank you
You can just set the start and end padding on the inner EditText to 0dp. Here's a screenshot with Show Layout Bounds turned on so you can see that the hints go all the way to the edge of the view. Save this answer.
The error text (even " ") will take/reserve some height in the TextInputLayout. If you also want to get rid of it then
<com.google.android.material.textfield.TextInputLayout
...
app:errorTextAppearance="@style/MyZeroSizeTextAppearance"
...
>
Text appearance:
<style name="MyZeroSizeTextAppearance">
<item name="android:textSize">0sp</item>
</style>
and then
textinputlayout.setError(" ");
Hope it's not too late, but the code behind setError
is:
if (!mErrorEnabled) {
if (TextUtils.isEmpty(error)) {
// If error isn't enabled, and the error is empty, just return
return;
}
}
this means a simple workaround would be:
textinputlayout.setError(" ");
please be advised, that this will make TextView with error message visible - so it will make TextInputLayout higher even if it will be empty
since this passes the not-so-well-thought-out case of handling an empty error message request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With