像这样使用 WebView 可以吗?
我在 src 中使用可绘制对象作为 webview 中的标记,这可行吗?
mWebView.loadDataWithBaseURL("","<table width=\"100%\"><tr><td style=\"text-
align:center; background-color:grey;\"><img src=\""+R.id.button+"\"/></td></tr>
</table>"+Question, "text/html", "utf-8", "");
I am using drawables in src for tag in webview would this work?
mWebView.loadDataWithBaseURL("","<table width=\"100%\"><tr><td style=\"text-
align:center; background-color:grey;\"><img src=\""+R.id.button+"\"/></td></tr>
</table>"+Question, "text/html", "utf-8", "");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
绝对不是。 HTML 需要图像的 URL。更不用说您指定的是小部件 ID,而不是可绘制资源。
也许您的设备较旧 - Clayson 先生链接的问题的一个答案表明
file:///android_res/
URL 仅适用于 Android 2.2 及更高版本。然而,
android.resource
方案已经存在了更长的时间:android.resource://[package]/[res type]/[res name]
例如:
android.resource://this.is.my.package/drawable/button
我还没有在
WebView
中尝试过这个,但值得一试。Absolutely not. HTML expects URLs for images. Not to mention that you are specifying a widget ID, not a drawable resource.
Perhaps your device is older -- one answer on the question that Mr. Clayson linked to suggests that
file:///android_res/
URLs only work on Android 2.2 and higher.However, the
android.resource
scheme has been around longer:android.resource://[package]/[res type]/[res name]
e.g.:
android.resource://this.is.my.package/drawable/button
I have not tried this in
WebView
, but it is worth a shot.