I want to set my android linkify text color to a custom color however mText.setLinkTextColor("#2f6699");
does not work, I have been searching for a built in method that will compile a hexidecimal value but I havent found one, any help will go a long way thanks
Asked
Active
Viewed 1.1k times
20

Adrian Cid Almaguer
- 7,815
- 13
- 41
- 63

Edmund Rojas
- 6,376
- 16
- 61
- 92
4 Answers
50
You should convert it to a Color. Try:
mText.setLinkTextColor(Color.parseColor("#2f6699"));

dougcunha
- 1,208
- 12
- 13
-
2What about WebView? `Spannable sp = new SpannableString(Html.fromHtml(html)); Linkify.addLinks(sp, Linkify.ALL); webView.loadDataWithBaseURL(path, Html.toHtml(sp), "text/html", "utf-8", null);` How to change link color in this situation? – Alex Semeniuk Apr 08 '14 at 11:55
2
Try something like this:
noteView.setLinkTextColor(Color.green);
If you want to set an hexadecimal color:
noteView.setLinkTextColor(Color.argb(int alpha, int red, int green, int blue));
Replacing alpha/red/green/blue with the desired values. The documentation on the Color class can be found here

Marcelo
- 1,471
- 3
- 19
- 22
1
As resources.getColor() function deprecated we can try this alternative way.
textView.setLinkTextColor(ContextCompat.getColor(this,R.color.colorBlue))
Thanks.

Geek Tanmoy
- 745
- 1
- 9
- 20