Reputation: 5381
I need to put some links in one TextView
. For better user experience, I would like to highlight the links when user click by changing the foreground/background colors of the links.
I have tried android:textColorLink
and TextView.setLinkTextColor(ColorStateList)
, but none of both works.
Any idea?
Upvotes: 1
Views: 1618
Reputation: 2442
I think a best way is using Spannable
Spannable sps=(Spannable )tv.getText();
sps.setSpan(new BackgroundColorSpan(Color.YELLOW), start, end, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
Upvotes: 1