Android remove underline from links in TextView

Here is the top Answer how to Remove underline from links in TextView in Android

private void stripUnderlines(TextView textView) {
        Spannable s = new SpannableString(textView.getText());
        URLSpan[] spans = s.getSpans(0, s.length(), URLSpan.class);
        for (URLSpan span: spans) {
            int start = s.getSpanStart(span);
            int end = s.getSpanEnd(span);
            span = new URLSpanNoUnderline(span.getURL());
            s.setSpan(span, start, end, 0);

Leave a Comment