package com.integreight.onesheeld.utils; import android.annotation.SuppressLint; import android.text.Spannable; import android.text.SpannableString; import android.text.TextPaint; import android.text.style.URLSpan; import android.widget.TextView; /** * Created by dell on 1/12/2017. */ @SuppressLint("ParcelCreator") public class URLSpanNoUnderline extends URLSpan { public URLSpanNoUnderline(String url) { super(url); } @Override public void updateDrawState(TextPaint ds) { super.updateDrawState(ds); ds.setUnderlineText(false); } public static 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); s.removeSpan(span); span = new URLSpanNoUnderline(span.getURL()); s.setSpan(span, start, end, 0); } textView.setText(s); } }