没发现有相关的属性,google一下都是重写Span。做个记录
private void stripUnderLines(TextView tv) {
try {
Spannable text = (Spannable) tv.getText();
if (text == null)
return;
URLSpan[] old = text.getSpans(0, text.length(), URLSpan.class);
if (old == null)
return;
for (int i = old.length - 1; i >= 0; i--) {
URLSpan us = old[i];
final int start = text.getSpanStart(us), end = text.getSpanEnd(us), flags = text.getSpanFlags(us);
text.removeSpan(us);
text.setSpan(new MyURLSpan(us.getURL()), start, end, flags);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private final class MyURLSpan extends URLSpan{
public MyURLSpan(String url) {
super(url);
}
public MyURLSpan(Parcel src) {
super(src);
}
public void updateDrawState(TextPaint ds) {
ds.setColor(ds.linkColor);
ds.setUnderlineText(false);
}
}
本文提供了一种在Android中去除TextView链接下划线的方法。通过重写URLSpan并覆盖updateDrawState方法,使得TextView内的链接不会显示下划线。
1608

被折叠的 条评论
为什么被折叠?



