WebView 内容中的位图不显示

发布于 2025-01-04 02:29:46 字数 139 浏览 5 评论 0原文

我尝试从 Android 中的 WebView 制作位图。但是,当我从 WebView 创建位图时,它已创建,但内容未显示(空白屏幕)。我还尝试过 WebViewClient 在页面完成后显示内容。但无法显示内容。有谁知道这个问题的答案吗?

谢谢。

I try to make a Bitmap from a WebView in Android. But when I create a Bitmap from WebView, it is created but content does not appear (blank screen). I have also tried WebViewClient to display content after page has been finished. But content cannot be displayed. Is there anybody who knows the answer of this?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

趁年轻赶紧闹 2025-01-11 02:29:46

这对我有用:

MY_VEB_VIEW.loadDataWithBaseURL("file:///android_asset/images/", "<img src='MY_IMAGE.png' />",
                "text/html", "utf-8", null);

This works for me:

MY_VEB_VIEW.loadDataWithBaseURL("file:///android_asset/images/", "<img src='MY_IMAGE.png' />",
                "text/html", "utf-8", null);
亽野灬性zι浪 2025-01-11 02:29:46
Bitmap bitm = ImageSelection.mWebView.getDrawingCache(true);

这是可行的..但是如果图像很小,位图中会有空白空间..
在 webview 中查看的图像被转换为​​位图。

Bitmap bitm = ImageSelection.mWebView.getDrawingCache(true);

This works..but you will have blank space in bitmap if image is small..
The image viewed in webview is converted to bitmap.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文