3

I'm using Android Design Library's TextInputLayout and TextInputEditText with a background. When setting an error, the field is highlighted with a rather jarring red background that my client dislikes.

I can style away the red background if I don't include the field border, but not if I use one. I've tried all the styling options that I've seen in the relevant S/O answers with no success.

I also tried setting the background in code after setting the error as described in the top answer here, and the red background is temporarily removed from the input field, but reappears as soon as the field is reentered. I tried adding a focus change listener and redoing the setBackgroundResource call, but I still get the red background. Stepping through with a debugger shows that there is a frame choreographer message posted that eventually adds the background color back. Since this approach always felt like a work-around, I haven't tried to post my own messages to set it back.

It appears to me that my desired background resource is being replaced by a background color one. Is there a way to style that away that I'm just not seeing? enter image description here enter image description here

Community
  • 1
  • 1
scottt
  • 8,301
  • 1
  • 31
  • 41

1 Answers1

1

i've managed to do it by putting transparent background like this

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:state_focused="true"
        android:top="5dp">
        <shape>
            <solid android:color="@android:color/transparent" />
            <stroke
                android:width="1dp"
                android:color="@color/colorWhite" />
            <corners android:radius="50dp" />
            <padding
                android:bottom="13dp"
                android:left="13dp"
                android:right="13dp"
                android:top="13dp" />
        </shape>
    </item>
</layer-list>