Bug 42382 - Hybrid webview do not resize html items on android
Summary: Hybrid webview do not resize html items on android
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Samantha Houts [MSFT]
Depends on:
Reported: 2016-07-06 13:33 UTC by Luca
Modified: 2017-06-19 18:28 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Project (136.80 KB, application/zip)
2016-07-07 10:08 UTC, Luca
Images samples (99.77 KB, application/zip)
2016-07-07 10:10 UTC, Luca

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Luca 2016-07-06 13:33:15 UTC
Xamarin forms HybridWebview fails to resize html images on android, if I try the same code on xamarin android app it works correctly.

HybridWebViewRenderer.cs sample code

public class HybridWebViewRenderer : ViewRenderer<HybridWebView, Android.Webkit.WebView>
		Android.Webkit.WebView webView = null;

		protected override void OnElementChanged (ElementChangedEventArgs<HybridWebView> e)
			base.OnElementChanged (e);

			if (Control == null) {
				webView = new Android.Webkit.WebView (Forms.Context);

                                webView.Settings.JavaScriptEnabled = true;
			        webView.Settings.AllowFileAccessFromFileURLs = true;
			        webView.Settings.AllowUniversalAccessFromFileURLs = true;
			        webView.Settings.LoadWithOverviewMode = true;
			        webView.Settings.UseWideViewPort = true;

                                SetNativeControl (webView);
			if (e.OldElement != null) {
			        var hybridWebView = e.OldElement as HybridWebView;
			        hybridWebView.Cleanup ();
                        if (e.NewElement != null) {
				Control.LoadUrl ("file:///android_asset/index.html");

Comment 1 Samantha Houts [MSFT] 2016-07-06 17:55:58 UTC
Thank you for taking the time to submit the bug. We tried to reproduce the issue you reported but were unable given the description. If you could please attach a reproduction to the bug by starting with a clean Xamarin.Forms project and adding just the code necessary to demonstrate the issue, we would very much appreciate it.  

For your convenience, we have created some reproduction best practices viewable here: https://gist.github.com/jassmith/92405c300e54a01dcc6d 
Warm regards, 
Xamarin Forms Team
Comment 2 Luca 2016-07-07 10:08:39 UTC
Created attachment 16599 [details]
Comment 3 Luca 2016-07-07 10:10:14 UTC
Created attachment 16600 [details]
Images samples

Correct and wrong samples
Comment 4 Luca 2016-07-13 06:37:52 UTC
Have you tried to reproduce the issue?
Best Regards
Comment 5 Luca 2016-07-21 02:57:38 UTC
Info provided
Comment 6 Samantha Houts [MSFT] 2016-07-21 18:33:26 UTC

I tried your reproduction on Xamarin Studio with a Nexus 7 API 23 emulator, and the images appear to be sized correctly and are not cut off. Are you testing with a particular device or emulator?
Comment 7 Luca 2016-07-25 01:50:37 UTC
Please let try with any phone in landscape orientation (both device and emulator)
Comment 8 Samantha Houts [MSFT] 2016-08-17 17:00:19 UTC

It seems to work properly in landscape orientation for me, as well. Can you provide more guidance?
Comment 9 Samantha Houts [MSFT] 2017-06-19 18:28:23 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!