android – Which theme attribute changes the text color of an EditText's error message-ThrowExceptions

Exception or error:

In my form I use setError("") on an EditText field. My Application-Theme extends android:Theme.Holo.
I have manually set an image with a dark background for android:errorMessageBackground and android:errorMessageBackgroundAbove.

And now here’s the problem: The text color of the error message is also very dark and not readable.

I tried changing different textColor attributes in my Theme, but I wasn’t able to find the correct one.

May anyone could help me, please?
Thank you!

How to solve:

You can change the text color by using HTML Font Tag.

But for customizing background color, you should make your own custom pop up.
For more information, Kindly go through this link:-
How to write style to error text of EditText in android?


You can try this one:

editText.setError(Html.fromHtml("<font color='red'>Error Message!</font>"));


do following in manifest.xml

    <style name="LightErrorFix" parent="@android:style/Theme.Light">
         <item name="android:textColorSecondaryInverse">@android:color/secondary_text_light</item>


Assuming you did sth like this:

EditText text = (EditText) findViewById(;

you can do the following:




or if you want/need alpha:


Anyhow, you should specify your colors in your color.xml (wayyy better to be maintained):

<color name="myColor">#f00</color>

and then use it like this:


Have fun 🙂


set the property
android:textColorPrimaryInverse="YourCOLOR" to the color nedded.


My response works, is in kotlin.

private fun setErrorOnSearchView(searchView: SearchView, errorMessage: String) {
    val id = searchView.context
            .getIdentifier("android:id/search_src_text", null, null)
    val editText = searchView.find<EditText>(id)

    val errorColor = ContextCompat.getColor(this,
    val fgcspan = ForegroundColorSpan(errorColor)
    val builder = SpannableStringBuilder(errorMessage)
    builder.setSpan(fgcspan, 0, errorMessage.length, 0)
    editText.error = builder

Leave a Reply

Your email address will not be published. Required fields are marked *