0

I need to shrink the size of the WebView and its contents to a smaller thumbnail type view.

I have html content of templates for postcards showing in a Xamarin Forms WebView. The size of the html is hardcoded in the styles. I want to display this content to the user showing the full html instead of showing part of the web page and having to scroll within the WebView to see all of it.

body {
    width:  6.25in;
    height:  4.5in;
    margin: 0;
    padding: 0;
  }

If I put in smaller heightrequest and widthrequest, only shows part of the page. So I thought if I put in a big enough widthrequest and use scale to shrink it down, it would work, however the width of the screen isn't big enough and gives the screenwidth size instead, so scale doesn't work either.

  • I'm not familiar with HTML, but I think what you want to achieve should be some setting in the HTML to set the website fill the webView. – nevermore Sep 24 '19 at 02:58
  • I can't change the HTML itself as it is used for actual printing of the post cards. If I were to change the size, I would have issues with font sizes and other artifacts so that it wouldn't show what would actually be printing. I need some way to zoom out. There are zoom controls that can be added, but that's for zooming "in" instead of out. – David Brenchley Sep 24 '19 at 20:04
  • How about set [scale to fit](https://stackoverflow.com/a/50019749/10539446) to webView? – nevermore Sep 26 '19 at 09:20
  • Thanks Jack for the suggestion. I tried this (for Android anyway) and it doesn't work. – David Brenchley Sep 28 '19 at 22:01
  • I comes up an other idea that you can put your webView inside a scrollview. Like the idea in [this answer](https://stackoverflow.com/a/6464847/10539446). You can set the width as big as you want in the scrollview. – nevermore Oct 01 '19 at 09:53
  • I never found a solution I liked. What I did as a work around, was writing a web api that translated html text to an image and resized it, then I linked to the web api from the image control. It's not the fastest, but at least it's working. – David Brenchley Nov 15 '19 at 17:56

0 Answers0