I would like to make a TextView to be entirely underlined but I can’t use a text resource and <u> tag because it is dynamic text.
So far the only way I know to do this is at runtime. Is this really the only way? Is there a way I could do it in the XML files?
The easiest solution is probably to create a custom UnderLineTextView component deriving from TextView, override setText() and set the entire text as underlined, something like this (underline code from the link you referred to above):
It’s then just a matter of using your new component in the layout and setting the text as usual. The rest is handled automatically.
More info on custom components:
http://developer.android.com/guide/topics/ui/custom-components.html