2

I Used edittext in TextInputLayout like below code:

<android.support.design.widget.TextInputLayout
            android:id="@+id/tilVoucherNo"
            android:layout_width="225dp"
            android:layout_height="wrap_content"
            android:layout_below="@id/imgVoucher"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="30dp"
            app:errorEnabled="true">

            <EditText
                android:id="@+id/editVoucher"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@drawable/default_edittext_line"
                android:hint="@string/xml_packages_voucher_input_hint"
                android:inputType="textEmailAddress"
                android:paddingBottom="10dp"
                android:paddingRight="25dp" />

        </android.support.design.widget.TextInputLayout>

with this dependecies:

compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:design:23.3.0'

enter image description here

but when i want to set background to edittext in error status its become like below image: enter image description here

i tried two solution for changing edittext background:

editVoucher.getBackground().setColorFilter(getResources().getColor(R.color.edittext_error_inactive_line), PorterDuff.Mode.SRC_IN);

and

editText.setBackground(getContext().getResources().getDrawable(R.drawable.error_edittext_line));

that error_edittext_line is:

    <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:top="-10dp"
    android:left="-10dp"
    android:right="-10dp"
    android:bottom="10dp"
    >
    <shape android:shape="rectangle">
        <stroke android:width="1dp" android:color="@color/edittext_error_active_line"/>
    </shape>
</item>
</layer-list>

I also try below shape for error_edittext_line but has same bug:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:right="-10dp" android:bottom="5dp" android:top="-10dp" android:left="-10dp">
    <shape
        android:shape="rectangle">
        <stroke android:width="1dp" android:color="@color/edittext_error_active_line" />
    </shape>
</item>

Ahmad Vatani
  • 1,630
  • 4
  • 21
  • 34
  • Try to change **PorterDuff** mode value like: `editText.getBackground().setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP);` – Dhruv May 17 '16 at 11:40
  • @DhruvVaishnav show nothing with your suggest code!! – Ahmad Vatani May 17 '16 at 12:03
  • @Ahmad, had u found any solution, i am also facing the similar issue if you find please share,http://stackoverflow.com/questions/37476005/textinput-layout-turns-editext-into-red-on-setting-error – Reprator May 27 '16 at 07:26
  • @VikramSingh nothing found yet! :( also if you find anything notify me. tnx :) – Ahmad Vatani May 28 '16 at 07:19
  • @Ahmad you should try to set the background to the`TextImputLayout` – pariola Jun 22 '16 at 11:51

0 Answers0