Changing background color and border color of an EditText widget using State List in Android

In this article, we will create an application which will demonstrate how to change the background color and border color of an EditText widget. Here, we are changing the default background color and border color of the EditText widget using 9-patch image files. The state list xml file is used to define the 9-patch image files for different states of the EditText widget.

For the screenshot of this application, please scroll to the end of this article.

6 Responses to Changing background color and border color of an EditText widget using State List in Android

I’ve created custom color 9-patch for edit text background, but they don’t scale right… when displayed, they are 2 times bigger than the standard ones… I tried using wrap_content or fixed height but nothing… I even re-sized the images but had no effect (being 9-patch they are rescaled to the big dimensions). You didn’t have this problem? Do you have any idea how can I fix this?