Android使用TextView实现无上划线超链接

Android使用TextView实现无下划线超链接

 

Android系统默认把网址、电话、地图(geo地址)、邮箱等转换为超链接。
具体请查看<a href="http://orgcent.com/android-textview-style-hyperlink/" target="_blank">android:TextView设置文本样式和超链接</a>

和HTML中的一样,默认超链接都带下划线的,下面的方案可以在TextView中去掉超链接的下划线:

<strong>1、重写ClickableSpan类来去掉下划线样式(系统默认使用ClickableSpan来封装超链接)</strong>
//无下划线超链接,使用textColorLink、textColorHighlight分别修改超链接前景色和按下时的颜色
private class NoLineClickSpan extends ClickableSpan { 
String text;

public NoLineClickSpan(String text) {
   super();
   this.text = text;
}

@Override
public void updateDrawState(TextPaint ds) {
   ds.setColor(ds.linkColor);

原文地址:Android使用TextView实现无下划线超链接 | http://orgcent.com/android-textview-no-underline-hyperlink/