简体   繁体   English

更改右侧图标样式错误 TextInputLayout

[英]Change style of the right icon error TextInputLayout

I want to change the style of the right icon error (the image with ! sign) in a TextInputLayout but I don't find how.我想更改TextInputLayout正确图标错误(带有 ! 符号的图像)的样式,但我不知道如何更改。

It is possible?.有可能吗?

文本输入布局

With the Material Component Library just use the app:errorIconDrawable attribute.使用 Material Component Library 只需使用app:errorIconDrawable属性。

Something like:类似的东西:

<com.google.android.material.textfield.TextInputLayout
    app:errorIconDrawable="@drawable/..."
    ../>

在此处输入图片说明

To do this in your Java class, you can do something like this:要在 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM