TextView添加下划线

Posted by PanMin on June 7, 2017

TextView添加下划线

在开发应用的过程中经常会遇到显示一些不同的字体风格的信息,如关键词高亮显示的等。有两种方式:

  • 使用多个TextView来实现
    tvTest.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG );
    tvTest.getPaint().setAntiAlias(true);//抗锯齿
    
  • 使用Html.fromHtml
    textView.setText(Html.fromHtml("<a href=\"http://www.baidu.com\" >" + text + "</a>"));