我无法在android webview中显示图像使用方法loadUrl(“http://www.zhihu.com/question/22091564/answer/25190954”);
也许js或css没有加载。我无法解决它。
像:
<img src="//s1.zhimg.com/misc/whitedot.jpg" data-rawwidth="1132" data-rawheight="659" class="origin_image zh-lightbox-thumb lazy" width="1132" data-original="http://p1.zhimg.com/85/dd/85dd508328e80af323a98e1d8e05db6a_r.jpg" data-actualsrc="http://p1.zhimg.com/85/dd/85dd508328e80af323a98e1d8e05db6a_m.jpg">
答案 0 :(得分:0)
试试这个:
public class YourActivity extends Activity {
private static final String HTML_FORMAT = "<html><body style=\"text-align: center; background-color: black; vertical-align: center;\"><img src = \"%s\" /></body></html>";
private WebView mWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
mWebView = (WebView) findViewById(R.id.yourWebView);
final String imgUrl = "http://xxx.xxx";
final String html = String.format(HTML_FORMAT, imgUrl);
mWebView.loadDataWithBaseURL("", html, "text/html", "UTF-8", "");
//not required but cant help
mWebView.getSettings().setUseWideViewPort(false);
}
}