【发布时间】:2020-08-19 05:16:27
【问题描述】:
我正在使用 WebView,我想在其中显示一个图像。
我想在 webview 中调整图像。 (图像变得如此之大,我不得不水平滚动)
我会展示这样的图片(如果重要的话):<img src="path" alt="">
我尝试过的:
WebView content = (WebView) findViewById(R.id.webView1);
content.loadDataWithBaseURL(null, "<style>img{display: inline;height: auto;max-width: 100%;}
</style>" + CONTENT, "text/html", "UTF-8", null);
但是当我使用这种方法时,图像是不可见的。只有文字
我也试过这个:
WebSettings settings = preview.getSettings();
settings.setLoadWithOverviewMode(true);
settings.setBuiltInZoomControls(true);
它可以工作,但它并不好,因为它缩小了 web 视图并且文本变得不可读。 有没有其他办法?
【问题讨论】:
标签: java android html image webview