I am using WebView in Xamarin.Forms to display html. It's not displaying entire html pages-- just the content which would normally be in the "body" section of an html page (i.e. <h1>Hello</h1>
).
However, when the webview is displayed on the page, the displayed html is far too small. Also, there is an issue where the webview does not fill the entire page, even though it should. *Both of these problems do not occur in Android.
Here are some screenshots of the way the html is displayed by the webview in iOS:
larger html element which does not extend to fill the entire page
Here is the code I have in my xaml file:
<WebView x:Name="webView" HeightRequest="1000" WidthRequest="1000">
<WebView.Source>
<HtmlWebViewSource x:Name="announcementHtml"/>
</WebView.Source>
</WebView>
And in the code behind, an argument called 'announcement' is passed to the constructor of the page, and I access the raw html with this code:
announcementHtml.Html = announcement.Announcement;
You could replicate this in your own project by simply creating a webview on a new page and hardcoding in an html element (like a
, , etc.).
I know that using a custom renderer is the way to solve these problems (or at least the issue of the size of the html), but I do not know how to implement a custom renderer.
Any help would be greatly appreciated!