Michael Zeuner Michael Zeuner - 1 year ago 217
Android Question

How do you underline a text in android xml?

How do you underline a text in the xml file? there is not a selection in the textStlye please help?

Answer Source

If you are using a string resource xml file (supports HTML tags), it can be done using<b> </b>, <i> </i> and <u> </u>.

    <string name="your_string_here">
        This is an <u>underline</u>.

If you want to underline something from code use:

TextView tv = (TextView) view.findViewById(R.id.tv);
SpannableString content = new SpannableString("Content");
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);

Hope this helps

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download