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.
1. Create new Android project namely “CustomEditTextDemo”
Figure 1 : New Android Project
2. Select Android build target
Select Android Build Target
3. Enter application details
Figure 3 : Enter Application Details
4. res/values/strings.xml
5. Download 9-patch image files
Download the 9-patch image files from the given below link and extract to the folder res/drawable-mdpi
6. res/drawable/edit_text.xml
This is the state list xml file that defines 9-patch images for different states of the EditText Widget
Источник