Thursday, 28 July 2011

Android: underline text programmatically

It's as easy as putting the following code in your Activity class...
TextView myTextView = new TextView(this);
SpannableString mySpannableString = new SpannableString("My String");
mySpannableString.setSpan(new UnderlineSpan(), 0, mySpannableString.length(), 0);
myTextView.setText(mySpannableString);

No comments: