public abstract class ClickableLinkSpan extends ClickableSpan{ private int selectedColor; public int linkColor; private boolean colored; private boolean underlined; /** * * @param selectedColor 选中时的背景色 * @param linkColor 文字颜色 * @param underlined 是否显示下划线 */ public ClickableLinkSpan(int selectedColor, int linkColor, boolean underlined) { this(selectedColor, linkColor, true, underlined); } ClickableLinkSpan(int selectedColor, int linkColor, boolean colored,boolean underlined) { this.selectedColor = selectedColor; this.linkColor = linkColor; this.colored = colored; this.underlined = underlined; } @Override public void updateDrawState(TextPaint ds) { if (colored) { ds.setColor(linkColor); }else { ds.setColor(ds.linkColor); } //设置无背景色 ds.bgColor = Color.TRANSPARENT; // 设置是否显示下划线 ds.setUnderlineText(underlined); } }