WebView wrap-content

前端 未结 10 2396
我寻月下人不归
我寻月下人不归 2020-12-13 02:26

Is it possible to load a URL in a WebView and resize it to fit the screen? I mean I want to make the WebPage small so that the user doesn\'t need to scroll. Is this possible

10条回答
  •  囚心锁ツ
    2020-12-13 03:04

    Set the initial scale to 1. It then zooms in to fill the screen. Haven't tested how this works on really tall web sites (blog posts with lots of comments for example) but it's working on a Droid X and an HTC Aria with a standard web page.

    WebView.setInitialScale(1);
    

    I'll continue testing with different web pages but so far this is the best solution I've got for this issue.

    EDIT: Tested with an obscenely long web page on both Droid X and Aria and got positive results on both. Setting the initial scale to 0 seems to turn the whole thing off resulting in initial scale being 100. I'm happy with these results, hope this helps others struggling with this issue.

提交回复
热议问题