Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android WebView概览模式加载放大的图像_Android_Image_Webview_Scale - Fatal编程技术网

Android WebView概览模式加载放大的图像

Android WebView概览模式加载放大的图像,android,image,webview,scale,Android,Image,Webview,Scale,我使用以下代码在WebView中显示图像: final WebView web = (WebView) findViewById(R.id.webView); web.getSettings().setJavaScriptCanOpenWindowsAutomatically(false); web.getSettings().setPluginsEnabled(false); web.getSettings().setSupportMultipleWindows

我使用以下代码在WebView中显示图像:

    final WebView web = (WebView) findViewById(R.id.webView);
    web.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
    web.getSettings().setPluginsEnabled(false);
    web.getSettings().setSupportMultipleWindows(false);
    web.getSettings().setSavePassword(false);
    web.getSettings().setBuiltInZoomControls(true);
    web.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    web.getSettings().setUseWideViewPort(true);
    web.getSettings().setLoadWithOverviewMode(true);
    String url = extras.getString("url");
    String x = "<html><head><meta name=\"viewport\" content=\"width=device-width\"/><style type=\"text/css\">html, body {margin: 0;padding: 0;} img {border: none;}</style><head><body style=\"background: black;\"><table><tr><td align=\"center\"><img src=\"" + url + "\" /></td></tr></table></body></html>";
    web.loadDataWithBaseURL(null, x, "text/html", "utf-8", null);
final WebView web=(WebView)findviewbyd(R.id.WebView);
web.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
web.getSettings().setPluginsEnabled(false);
web.getSettings().setSupportMultipleWindows(false);
web.getSettings().setSavePassword(false);
web.getSettings().SetBuilTinZoomControl(true);
setScrollBarStyle(WebView.SCROLLBARS\u外部\u覆盖);
web.getSettings().setUseWideViewPort(true);
web.getSettings().setLoadWithOverview模式(true);
字符串url=extras.getString(“url”);
String x=“html,body{margin:0;padding:0;}img{border:none;}”;
loadDataWithBaseURL(null,x,“text/html”,“utf-8”,null);

根据手册,它应该在概览模式下启动,所以应该最大限度地缩小(这就是我想要做的)。不幸的是,图像被放大了。如何修复它?

我认为这里发生的事情是
width=devicewidth
表示视口应该是480像素宽(或者不管设备是什么)。因此,一个比这更宽的图像将部分脱离屏幕,需要滚动


如果您希望页面以概览模式打开,我认为您应该在创建WebView时设置该模式,并且不要指定任何
视口

,如果您链接到说明此操作应该有效的手册,则会有所帮助。。。