Android Linkify how to set custom link color?
10,386
Solution 1
You should convert it to a Color. Try:
mText.setLinkTextColor(Color.parseColor("#2f6699"));
Solution 2
You can use also android:textColorLink="#2f6699"
in xml.
Solution 3
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
Related videos on Youtube
Author by
Edmund Rojas
Updated on June 04, 2022Comments
-
Edmund Rojas almost 2 years
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 -
Alex Semeniuk about 10 yearsWhat 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?