Issue
How can I define underlined text in an Android layout xml
file?
Solution
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>
.
<resources>
<string name="your_string_here"><![CDATA[This is an <u>underline</u>.]]></string>
</resources>
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);
textView.setText(content);
Answered By - Anthony Forloney
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.