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'
but when i want to set background to edittext in error status its become like below image:
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>