How to write style to error text of EditText in android?

前端 未结 7 1803
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 12:37

I\'m trying to write new custom style for my android application. I need to give style to errorText which appears after setting setError in EditText

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 13:09

    I don't think you can customize its style that way since the error popup uses an internal style:

    mPopupInlineErrorBackgroundId = getResourceId(mPopupInlineErrorBackgroundId,
                        com.android.internal.R.styleable.Theme_errorMessageBackground);
    mView.setBackgroundResource(mPopupInlineErrorBackgroundId);
    

    However, you can set a Spanned and a custom error icon using the overloaded setError(CharSequence, Drawable).

    You can easily create a Spanned from HTML using fromHtml().

    However, you still won't be able to set the popup background image :-(

提交回复
热议问题