1. 在资源文件中使用HTML样式
<resources> <string name="underline_text">this is a <u>underline</u></string> </resources>
TextView tv=new TextView(this); tv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);//下划线
TextView textView = (TextView) view.findViewById(R.id.textview); SpannableString content = new SpannableString("Content"); content.setSpan(new UnderlineSpan(), 0, content.length(), 0); textView.setText(content);
TextView tv=new TextView(this); tv.setText(Html.fromHtml("<a href=\"http://blog.csdn.net/CAIYUNFREEDOM\">自定义的超链接样式</a>"));