vanomart vanomart - 6 months ago 76
Android Question

Change underline color for TextView

How can I change underline color for TextView in Android? Desired result shown below:
Underline color

Default is some kind of blue (probably holo blue), but I need to change this to orange. The problem is, I don't know how exactly is this called (is this underline, indicator or what?), so I'm not able to google this on my own.



You have two options, for a basic edit text you could use either of these. The second option is not covered in the question flagged by karaokyo and would be my preference to reduce application size.

You can use the Android Holo Colors web app to generate custom themes, you choose the color and which controls you want and it generates the 9 patches and appropriate theme files. May require a little tinkering to get it to fit into your current project but all you need is in the generated zip.

Alternatively with Android 5 you have Widget Tinting, which is also supported in older Android versions by using AppCompat v21. This does all the coloring for you without all the extra resources to include. Note that this doesn't work everywhere yet but if you are using a plain edit text on an activity it should be ok. Full details of implementation here