Janusz Janusz - 1 year ago 78
Android Question

Can I underline text in an android layout?

How can I define underlined text in an Android layout


Answer Source

It can be achieved if you are using a string resource xml file, which supports HTML tags like <b></b>, <i></i> and <u></u>.

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

If you want to underline something from code use:

TextView textView = (TextView) view.findViewById(R.id.textview);
SpannableString content = new SpannableString("Content");
content.setSpan(new UnderlineSpan(), 0, content.length(), 0);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download