How to work with TextFormatted property of a TextView control?
I am working with a TextView control in android Xmarine c# project. Here I need to make a textview as hyperlink to open another page. I have given text colour as orange for that TextView. But If I use the below mentioned code for the Textview Control, the colour turned into blue automatically.
string DATA = "https://forums.xamarin.com"; TextView.TextFormatted = Html.FromHtml("<a href=" + DATA + ">" + "ABCD" + "</a>"); TextView.MovementMethod = LinkMovementMethod.Instance;
Here I need to make a textview as hyperlink but with the custom colour. How can it possible?
in Xamarin.Android, you can set the Hyperlink color directly within the TextView object via:TextView.SetLinkTextColor(Android.Graphics.Color.Red);
This changes the Hyperlink color to red for example.
Answers
in Xamarin.Android, you can set the Hyperlink color directly within the TextView object via:
TextView.SetLinkTextColor(Android.Graphics.Color.Red);
This changes the Hyperlink color to red for example.
https://developer.xamarin.com/api/member/Android.Widget.TextView.SetLinkTextColor/p/Android.Graphics.Color/
Thank you @AmmarMheir
this is working perfect. Can you please help me with one more thing , i.e. Colour is coming Orange now(As i made it as orange). but the text is coming with an underline.
Can we remove this underline from code behind for TextView control, as I don't want to give underline.
@soumenhalder Here is how you remove the underline:
Create a custom span class to handle stripping out the underlines.
Create an extension method to find all url spans and replace them with our custom spans.
To create hyperlink is just a few line of code no need xml
Result
