Skip to content

Instantly share code, notes, and snippets.

@androidcodehunter
Created October 13, 2016 05:31
Show Gist options
  • Save androidcodehunter/fdd4efc1cbb3b5c9deb69f3cb0dca727 to your computer and use it in GitHub Desktop.
Save androidcodehunter/fdd4efc1cbb3b5c9deb69f3cb0dca727 to your computer and use it in GitHub Desktop.
Removing highlighted color from ClickableSpan in Android
I’ve been struggling for some hours with TextView and Spannable.. ClickableSpan to be precise. It seems that when you tap the clickable text it gets an ugly orange stroke (might differ on devices) around the text and if you so happen to have this in a custom view as an item in e.g Gallery it really stands out by highlighting it everytime you scroll away from that view. Annoying, yes?
The solution is extremely simple and was provided by a thread over at Stackoverflow.com.
To edit or remove the higlight color you can simply set the TextViews highlight color itself to any color you want or Color.TRANSPARENT if you don’t want any color.
android:textColorHighlight="@color/something"
or in code
textView.setHighlightColor(Color.TRANSPARENT);
@fawaz-ahmed
Copy link

In my case I had to add a bit different color which is transparent whte

android:textColorHighlight="#00FFFFFF"

@gianluca-tesio-MELI
Copy link

Gracias por la solución!!

@TedaLIEz
Copy link

TedaLIEz commented Mar 4, 2020

Thanks, you save the day!

@kukabi
Copy link

kukabi commented Mar 26, 2020

thanks so much!

@ssensalo
Copy link

Thanks a lot

@htteng1976
Copy link

Thanks, you save my day :)

@yangxiaobinhaoshuai
Copy link

Thanks, save my day, bro ! 🍺

@androidcodehunter
Copy link
Author

androidcodehunter commented Jul 24, 2020 via email

@hiepxuan2008
Copy link

Set android:textColorHighlight="#00FFFFFF" works, set android:textColorHighlight="@android:color/transparent" doesn't work. Thank @fawaz-ahmed

@dramirezm
Copy link

android:textColorHighlight="#00FFFFFF" works , thanks

@akshithb19
Copy link

Set android:textColorHighlight="#00FFFFFF" works, set android:textColorHighlight="@android:color/transparent" doesn't work. Thank @fawaz-ahmed

Thanks a lot. This works.

@SerendipityMatthew
Copy link

you save my life

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment