androidtextviewclickablespan

ClickableSpan - How to remove color on text when added?


I've used ClickableSpan on a TextView. Upon adding the span, the color of text where it has been applied was changed too.

Checking SO questions, what I've seen are changed color after it was clicked. In my case, the color is already different upon rendering the view.

How can I remove the color from the ClickableSpan?


Solution

  • Clickable span have updateDrawState(TextPaint ds) method. set same color as you text color for clickable span also. so it will look same (2nd Approch)

    @Override public void updateDrawState(TextPaint ds) {
        //super.updateDrawState(ds);
        ds.setColor(linkColor);
        ds.setUnderlineText(false); // set to false to remove underline
    }