简体   繁体   English

Android WebView缩放以适合宽度

[英]Android WebView Zoom to fit Width

I'm calling a webpage that has only a 240px width div. 我正在呼叫一个只有240px宽度div的网页。

I can't edit the HTML contents, and the width is always 240px. 我无法编辑HTML内容,宽度始终为240px。

How can I make android webview to ZOOM IN to fit the 240px table in the whole width of the webview? 如何将android webview缩放为适合整个webview宽度的240px表格?

I've tested: 我已经测试过:

settings.setUseWideViewPort(false);

and also several combinations of meta viewport, like: 以及元视口的几种组合,例如:

<meta name="viewport" content="width=240" />
<meta name="viewport" content="width=device-width" />

How can I force this behaviour? 我该如何强制这种行为?

You can try this, it works for me: 您可以尝试一下,它对我有用:

int default_zoom_level=100;
webview1.setInitialScale(default_zoom_level);

or 要么

int scale = 100 * webView1.getScale();
webview1.setInitialScale(scale);

Hope that helps 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM