我尝试将网页的全部内容显示到WebView
中。文本显示正确,但图像显示不正确。我搜索了很多帖子,但没有一个对我有帮助。这是我尝试过的:
webView = myFragment.findViewById(R.id.web_view);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setUseWideViewPort(true);
webSettings.setDomStorageEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
webView.loadUrl(URL);
webView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
progressBar.setVisibility(View.GONE);
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
Log.d(TAG, "Error: " + description);
}
});
我传递给URL
函数的loadUrl()
看起来像这样:
mydomain.com/category/category_name/
我也尝试过:
mydomain.com/category/category_name/index.php
但是它不显示图像,仅显示文本。该怎么解决?
任何帮助将不胜感激,谢谢!
答案 0 :(得分:0)
尝试
webSettings.setJavaScriptEnabled(true);
webSettings.setBlockNetworkImage(false);