Hello, everyone! I want to fit scale of a non-responsible web page loaded in WebView on Android and
iOS platforms both. To do it I created CustomWebView class inherited from the WebView. Also I created custom renderer CustomWebViewRenderer to render CustomWebView using features of concrete platform. But page is still loaded larger than screen size. Can somebody help me? Here is my code below. Thanks in advance!
public class CustomWebView: WebView{ }
[assembly: ExportRenderer(typeof(CustomWebView), typeof(CustomWebViewRenderer))]
namespace MyProject.iOS
{
public partial class CustomWebViewRenderer : WebViewRenderer
{
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged (e);
if (e.OldElement == null) {
this.ScalesPageToFit = true;
}
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Core.Views;assembly=Core.Views"
x:Class="XamlSamples.HelloXamlPage">
<ContentPage.Content>
<local:CustomWebView Source="http://tsu.tula.ru" />
</ContentPage.Content>
</ContentPage>