How to change line color in EditText How to change line color in EditText xml xml

How to change line color in EditText


This is the best tool that you can use for all views and its FREE many thanks to @Jérôme Van Der Linden.

The Android Holo Colors Generator allows you to easily create Android components such as EditText or spinner with your own colours for your Android application. It will generate all necessary nine patch assets plus associated XML drawable and styles which you can copy straight into your project.

http://android-holo-colors.com/

UPDATE 1

This domain seems expired but the project is an open source you can find here

https://github.com/jeromevdl/android-holo-colors

try it

this image put in the background of EditText

android:background="@drawable/textfield_activated"

enter image description here


UPDATE 2

For API 21 or higher, you can use android:backgroundTint

<EditText        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:hint="Underline color change"        android:backgroundTint="@android:color/holo_red_light" />

Update 3Now We have with back support AppCompatEditText

Note: We need to use app:backgroundTint instead of android:backgroundTint

<android.support.v7.widget.AppCompatEditText   android:layout_width="match_parent"   android:layout_height="wrap_content"   android:hint="Underline color change"    app:backgroundTint="@color/blue_gray_light" />

Update 4AndroidX version

  <androidx.appcompat.widget.AppCompatEditText    app:backgroundTint="@color/blue_gray_light" />


I don't like previous answers. The best solution is to use:

<android.support.v7.widget.AppCompatEditText      app:backgroundTint="@color/blue_gray_light" />

android:backgroundTint for EditText works only on API21+ . Because of it, we have to use the support library and AppCompatEditText.

Note: we have to use app:backgroundTint instead of android:backgroundTint

AndroidX version

<androidx.appcompat.widget.AppCompatEditText      app:backgroundTint="@color/blue_gray_light" />


You can also quickly change the EditText's underline color by tinting the background of the EditText like so:

<EditText            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:hint="Something or Other"            android:backgroundTint="@android:color/holo_green_light" />