android - EditText 上的自定义错误文本边框 android

标签 android android-edittext android-theme errortemplate

我想创建自定义 errorTextEditText 意味着全边框。

editeText.setError(" ");

给出带有红色边框的错误消息,这有助于显示它是必需的或验证字段。

我创建了自定义错误消息,其中只有图标不同。

Snipped 用于更改错误消息的图标:-

    final Drawable error_indicator;
    error_indicator = getResources().getDrawable(R.drawable.error_icon_mdpi);
    int left = 0;
    int top = 0;
    int right = error_indicator.getIntrinsicHeight();
    int bottom = error_indicator.getIntrinsicWidth();
    error_indicator.setBounds(new Rect(left, top, right, bottom));
    addSxName.setError("Enter patient name in here", error_indicator);

这是它的样子。

What i got

我在找什么:-

What I'm looking for

但作为工具提示或其他东西,红色边框有点吸引眼球。

我们可以修改那个errorBox的modify吗?

最佳答案

不可能

替代解决方案

  1. 不要使用 setError()
  2. 创建自定义弹出窗口
  3. 创建您自己的设置错误方法并在那里显示弹出窗口

关于android - EditText 上的自定义错误文本边框 android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21086050/

相关文章:

继承自两个父主题的 Android XML 主题?

android - 我如何找到什么?android :attr/listChoiceIndicatorSingle points to?

android - 文件输出流日志

java - 无法从 ViewHolder (RecyclerView) 调用 Adapter 中的方法

android - 在 java 文件中创建 android gallery View

android-edittext - 在Android中动态创建EditText

android - 如何在 android 中将 db.zip 从 Assets 复制到 SD 卡

android - 如何在android EditText中添加千位分隔符.........?

android - Editor.java IndexOutOfBoundsException offset(x) 应该小于 line limit(y)

android - 设置 Theme.Holo.Light 会更改列表中除复选框以外的所有内容