Xamarin Forms控件,可以在其中显示HTML格式的文本 [英] Xamarin Forms control where I can show HTML formated text

查看:313
本文介绍了Xamarin Forms控件,可以在其中显示HTML格式的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Xamarin的新手,我尝试在Xamarin Form控件中显示HTML文本.

I'm new in Xamarin and I try to show a HTML text in a Xamarin Form control.

例如,如果我有以下HTML文本:

For example, if I have the following HTML text:

<ul>
<li>First</li>
<li>Second</li></ul>

它应该在Xamarin应用程序中显示以下结果:

It should show the following result in the Xamarin app:

  • 第一
  • 第二

有控制吗?

感谢您的帮助.

推荐答案

> WebView :

您可以使用WebView打开本地HTML文件以显示它.

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是您的本地HTML文件.*

**** index.html is your local HTML file.*

HtmlWebViewSource : 或者,如果您想呈现在代码中动态定义的HTML字符串,则需要创建 HtmlWebViewSource 的实例:

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;

这篇关于Xamarin Forms控件,可以在其中显示HTML格式的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆