我打算在Webview中显示来自SD卡的图片,以利用Webview内置的缩放功能。但是,我遇到了一个问题:显示比屏幕尺寸大的图像(例如1800x1200)以适应屏幕最初的大小,就像在ImageView中一样。我希望图片一开始就能完整地显示,并为用户提供缩放控制。
我已经尝试使用WRAP_CONTENT设置Webview的宽度和高度,但这并没有起作用。有什么想法吗?以下是我正在使用的代码片段:
String path = getRealPathFromURI(mUriList.get(0)); // this gets the file path
webView = (WebView) findViewById(R.id.WebView01);
WebSettings settings= webView.getSettings();
settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
webView.loadUrl("file://" + path);