user3000624 user3000624 - 1 month ago 11x
Android Question

Xamarin Android Webview Linkify email addresses

I am trying to understand how I can get my WebView to "Linkify" the email addresses. I want the email address to generate a hyperlink with mailto tag. All the browsers seems to be able to do this automatically. I am trying the following but I still do no get the links to show in the WebView UI.

HtmlString = "<html><head></head><body><label>Email:</label><span></span></body></html>"
SpannableString sp = new SpannableString(HtmlString);
Linkify.AddLinks(sp, MatchOptions.EmailAddresses);
string linkifiedContent = sp.ToString();

WebView.LoadDataWithBaseURL(BaseURL, linkifiedContent, MimeType, null, null);


Linkify is mostly used with TextView. It is used to create clickable links inside TextView.

In your case, you are already making use of WebView. Hence, you can just add the email address inside <a> tags:

var HtmlString = "<html><head></head><body><label>Email:</label><span><a href=''><a/></span></body></html>";

webView.LoadData(HtmlString, "text/html", "UTF-8");

This should load your Html content perfectly.

enter image description here

Happy coding!