Home » Android » Android – Linkify, autoLink remove text color change on touch

Android – Linkify, autoLink remove text color change on touch

Posted by: admin June 15, 2020 Leave a comment


Let’s say I have following text in TextView:

Hey there, visit www.example.com

If I set TextView’s attribute autoLink=”all” www.example.com will be properly detected. However, if I now touch TextView, TextView’s text that’s not link (‘Hey there, visit’ part) will go gray. Is there a way to prevent this behavior?


How to&Answers:

In xml you can simply do following:

Set color for text with:


Set color for links with:



If you can get away with doing it in code instead of XML, the trick below worked for me even though it’s kind of redundant. You’re basically setting the text color to what it is now. It’s not necessarily “white” as others have said; it’s a shade of gray. Regardless of the color, this gets it and sets it again.

final TextView message = new TextView(TheApp.this);  
final SpannableString s = new SpannableString("Some text with example.com in it.");
Linkify.addLinks(message, Linkify.WEB_URLS);


Tried changing any of these properties of your TextView ?

android:focusable - Boolean that controls whether a view can take focus. 

android:focusableInTouchMode - Boolean that controls whether a view can take focus while in touch mode. 

android:hapticFeedbackEnabled - Boolean that controls whether a view should have haptic feedback enabled for events such as long presses. 

android:clickable - Defines whether this view reacts to click events. 

I guess setting one of these to false would disable the visual feedback on the text elements.


Guys, looks like a weird bug to me, but i found a solution, use HTML to give the text a shade of white:


That’s it! With #FFFFFF it blinks, without, not. duh.