I have on my app Theme.Holo but I want to change the color of the underline border of edittext.
I don't want a full border around the edittext. I just want to change the color of the edittext layout on version 4.0+ .
How can I do this?
You could use 9patch. This resource is wonderful example: android holo
int color = Color.parse("#HEX")
editText.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
I think you can change android:background to your desired drawable to replace your edit text's default background.
For those that want a more complete answer. The default color is actually a 9- patch background. So you will need to replace it.
Go to http://android-holo-colors.com/. Here you will see a category called "color".
Click on the colored square beside it and you will see a color swatch come up. Change the color to that desired.
Scroll down and find another category called EditText. Click the yes button beside it.
Finally scroll down to the end of the page and download the generated zip.
Decompress the zip on your computer. You will find a couple of drawable folders according to the different pixel densities. Copy them to the appropriate folders in your project.
There will also be a folder simply called "drawable". In it will be an xml file. If you have a folder called "drawable", different from "drawable-mdpi, drawable-hdpi, etc", copy the xml file to the "drawable" folder, else create one in your "res" folder
Lastly, copy the name of the xml file. Go to the EditText you would like to change and set the xml file as your background. If your xml file was titled edit_text_holo_light, the xml code you would put in your EditText would be:
android:background="@drawable/edit_text_holo_light
Save the project and run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With