I am using Linkify
in my app, and visited link text is appearing as dark purple. My overall layout background color is dark blue so this is impossible to read.
It turned out to be a simple solution!
However you won't be able to do the visited
/ not visited
differentiation.
TextView contactWeb1 = (TextView) findViewById(R.id.contactWeb1);
noteView.setText("http://www.blablaasd.com/");
noteView.setLinkTextColor(Color.red); //for example
Linkify.addLinks(noteView, Linkify.ALL);
My attempts to catch visited states:
Use
noteView.setLinkTextColor(getResources().getColorStateList(R.color.colors));
Instead of
noteView.setLinkTextColor(Color.red);
In res/
create folder color
and create colors.xml
in res/color/
colors.xml
-
-
I have tried my best to catch visited states. I tried all the states a selector can take.
I might have missed In case you found out, share (:
ALTERNATE SOLUTION (works only for html links)
Set the font Color programatically
Drawback (Be carefull for this point)
You will have to catch whether it was visited or not (this is doable)
This means that you are not overriding the visited links functionality.
CODE:
TextView contactWeb1 = (TextView) findViewById(R.id.contactWeb1);
String desc = "Visit my site";
contactWeb1.setText(Html.fromHtml(desc));
contactWeb1.setMovementMethod(LinkMovementMethod.getInstance());