skip to Main Content

enter image description hereI can’t change background color of error text box color.

Want to change the background color of error box not text color.The way i tried to set setErrorTextColor,setErrorColor,setBackGroundColor not defined. kindly suggest some solution.
Thanks in advance.

2

Answers


  1. You can change the color of the error block of editText by using the following code.

    yourEditText.setErrorColor(Color.parseColor("Pass Your Color Code"));
    
    Login or Signup to reply.
  2. I would recommend you switch to Material.io TextInputLayout which not only provides a smoother error handling API but also has more customization features

    <com.google.android.material.textfield.TextInputLayout
    android:id="@+id/textField"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/label">
    
    <com.google.android.material.textfield.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
    />
    
    </com.google.android.material.textfield.TextInputLayout>
    

    For an in-depth documentation of all the features that come with Material.io version of Edittext, go to Material.io Text Field – Android

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search