问题
I'm new in Xamarin and I try to show a HTML text in a Xamarin Form control.
For example, if I have the following HTML text:
<ul>
<li>First</li>
<li>Second</li></ul>
It should show the following result in the Xamarin app:
- First
- Second
Is there a control for that?
Thanks for any help.
回答1:
WebView:
You can use WebView to open an local HTML file to display it.
webviewjava.BaseUrl = DependencyService.Get<IBaseUrl>().Get();
webviewjava.Source = "index.html";
**** index.html is your local HTML file.*
HtmlWebViewSource: Or If you want to present a string of HTML defined dynamically in code, you'll need to create an instance of HtmlWebViewSource:
var browser = new WebView();
var htmlSource = new HtmlWebViewSource();
htmlSource.Html = @"<html><body>
<h1>Xamarin.Forms</h1>
<p>Welcome to WebView.</p>
</body></html>";
browser.Source = htmlSource;
来源:https://stackoverflow.com/questions/47776370/xamarin-forms-control-where-i-can-show-html-formated-text