问题
I want to change the style of the right icon error (the image with ! sign) in a TextInputLayout
but I don't find how.
It is possible?.
回答1:
With the Material Component Library just use the app:errorIconDrawable
attribute.
Something like:
<com.google.android.material.textfield.TextInputLayout
app:errorIconDrawable="@drawable/..."
../>
回答2:
To do this in your Java class, you can do something like this:
// initialize your drawable object
Drawable myErrorDrawable = getResources().getDrawable(R.drawable.my_error_drawable);
// set the dimension/bounds
myErrorDrawable.setBounds(0, 0, myErrorDrawable.getIntrinsicWidth(), myErrorDrawable.getIntrinsicHeight());
// attach the drawable to your EditText.
editText.setError("An error occured", myErrorDrawable);
来源:https://stackoverflow.com/questions/37974299/change-style-of-the-right-icon-error-textinputlayout