How do I change the background of the TextInputLayoutText error when using a border?

I am using Android Design Library TextInputLayout and TextInputEditText with background. When setting the error, the field is highlighted with a rather harsh red background, which my client doesn't like.

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

I also tried to set the background in the code after setting the error as described in the top answer here and the red background is temporarily removed from the input field but appears as soon as the field is re-entered. I tried adding a focus change listener and calling setBackgroundResource again, but I still get a red background. Stepping through the debugger reveals that there is a frame choreographer message that eventually adds the background color. Since this approach has always seemed like a workaround, I have not tried posting my own posts to get it back.

It looks to me like my desired background resource is being replaced with a background color. Is there a way to remove this style that I just can't see? enter image description here enter image description here

+3


source to share


1 answer


I managed to do it by putting a 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>

      

+1


source







All Articles