1

Is it possible to change TextInputLayout error BACKGROUND color, not the text one from transparent to red for example?

Igor Mańka
  • 183
  • 1
  • 1
  • 11
  • https://stackoverflow.com/questions/36063847/issue-in-changing-edittext-background-after-setting-error-to-the-textinputlayout it should help you – Sachin Rajput Mar 13 '18 at 10:17
  • Possible duplicate of [Programmatically set TextInputLayout Hint Text Color and Floating Label Color](https://stackoverflow.com/questions/35683379/programmatically-set-textinputlayout-hint-text-color-and-floating-label-color) – Rome_Leader Mar 13 '18 at 12:33

2 Answers2

0

Create style in style.xml

<style name="error_appearance" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/red_500</item>
    <item name="android:textSize">12sp</item>
</style>

And use it in your TextInputLayout widget:

 <android.support.design.widget.TextInputLayout
            android:id="@+id/emailInputLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:errorTextAppearance="@style/error_appearance">
matin sayyad
  • 575
  • 3
  • 10
0

Add latest material dependecies in gradle and use setError

compile 'com.android.support:design:25.0.0'

emailInputLayout =(TextInputLayout)findViewbyId(R.id.emailInputLayout);
Spannable errorMsg = new SpannableString("Email cannot be Empty ");

errorMsg.setSpan(new ForegroundColorSpan(Color.BLUE), 0, errorMsg.length(), 
 Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
errorMsg.setSpan(new BackgroundColorSpan(Color.WHITE), 0, errorMsg.length(), 
 Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

emailInputLayout.setError(errorMsg);

This works fine.

Akila
  • 715
  • 2
  • 8
  • 13