【发布时间】:2016-10-24 18:22:13
【问题描述】:
我想更改 TextInputLayout 中右侧图标错误(带有 ! 符号的图像)的样式,但我不知道怎么做。
有可能吗?
【问题讨论】:
-
你能提供你现在使用的代码吗。看起来你在edittext上设置错误。
标签: android android-textinputlayout material-components material-components-android
我想更改 TextInputLayout 中右侧图标错误(带有 ! 符号的图像)的样式,但我不知道怎么做。
有可能吗?
【问题讨论】:
标签: android android-textinputlayout material-components material-components-android
要在您的 Java 类中执行此操作,您可以执行以下操作:
// 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);
【讨论】: