TextInputLayout Edittext foreground color change

290 Views Asked by At

I am using TextInputLayout around edittext to display hint and error. Hint is working perfectly fine as expected, but on using setError on TextInputLayout, the whole edittext is getting foreground colored. I just want the bottom highlight line to be colored not the whole box. The current behaviour is as below: enter image description here

Code on how I used it in layout is as below:

<android.support.design.widget.TextInputLayout
                android:id="@+id/inputLoginEmail"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/TextLabel">

                <EditText
                    android:id="@+id/etLoginEmail"
                    style="@style/EditTextStyle"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="@string/text_email_address"
                    android:imeOptions="actionNext"
                    android:inputType="textEmailAddress" />
            </android.support.design.widget.TextInputLayout>

The Style which is been used is as below:

<style name="TextLabel" parent="Widget.Design.TextInputLayout">
    <item name="android:textColorHint">@color/COLOR</item>
    <item name="android:textSize">@dimen/font_larger</item>
    <item name="colorAccent">@color/COLOR</item>
    <item name="colorControlNormal">@color/COLOR</item>
    <item name="colorControlActivated">@color/COLOR</item>
</style>

EditTextStyle:

<style name="EditTextStyle">
    <item name="android:textSize">@dimen/font_normal</item>
    <item name="android:textColor">@color/grey_text</item>
    <item name="android:fontFamily">@font/gotham_book</item>
    <item name="android:paddingBottom">@dimen/spacing_normal</item>
    <item name="android:paddingTop">@dimen/spacing_normal</item>
    <item name="android:background">@drawable/edittext_background</item>
</style>

edittext_background.xml

<?xml version="1.0" encoding="utf-8"?>

<item>
    <shape>
        <solid android:color="@color/grey_edittext_line" />
    </shape>
</item>

<item android:bottom="1dp">
    <shape android:shape="rectangle">
        <solid android:color="#FFFFFF" />
    </shape>
</item>

How can I remove this foreground color and get the color only on 1dp of highlighted line as in password?

0

There are 0 best solutions below