【问题标题】:WebView with custom CSS带有自定义 CSS 的 WebView
【发布时间】:2018-04-23 13:27:37
【问题描述】:

我正在开发一个带有 WebView 的 Xamarin.Forms PCL 项目,并尝试附加自定义 css。

我尝试将我的 Android .css 文件放在 Assests 文件夹中,将 iOS 放在 Resources 文件夹中,两者都称为 default.css

我的 HTML 是

<html><head><link rel=\"stylesheet\" href=\"default.css\"></head><p></p>

它适用于 Android 并使用 css。问题在于iOS它不使用css文件。我也在使用 Xamarin Live Player 进行 iOS 调试,但我认为它支持 css 文件。

【问题讨论】:

    标签: xaml xamarin xamarin.forms


    【解决方案1】:

    我认为您需要在 Xamarin 表单的官方文档中查看此项目。

    它在资源中有一个带有样式 css 文件的 HTML。注意default.css

    htmlSource.Html = @"<html>
    <head>
        <link rel=""stylesheet"" href=""default.css"">
    </head>
    <body>
        <h1>Xamarin.Forms</h1>
        <p>The CSS and image are loaded from local files!</p>
        <img src='XamarinLogo.png'/>
        <p><a href=""local.html"">next page</a></p>
        </body>
    </html>";
    

    这里是示例,其中有一个指向带有完整描述的原始文档的链接。 Working with WebView

    如果这没有帮助,您需要向我们展示您已完成的步骤。

    【讨论】:

      猜你喜欢
      • 2016-07-28
      • 1970-01-01
      • 2016-03-25
      • 1970-01-01
      • 1970-01-01
      • 2013-04-22
      • 2017-08-21
      • 2012-10-30
      • 1970-01-01
      相关资源
      最近更新 更多