drcarter의 DevLog

underline textview

Android2014. 11. 19. 10:03

1. SpannableString

2. setPaintFlags

3. Html.fromHtml


SpannableString

String udata="SpannableString underline sample";
SpannableString content = new SpannableString(udata);
content.setSpan(new UnderlineSpan(), 0, udata.length(), 0);
mTextView.setText(content);



setPaintFlags

mTextView.setPaintFlags(mTextView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
mTextView.setText("Paint flag underline sample");



Html.fromHtml

String htmlString="Html from underline sample";
mTextView.setText(Html.fromHtml(htmlString));