从网上找了各种博客代码拿来都不行,刚从同事那里整来几句代码,放上居然好用了,代码如下
WebSettings settings = webView.getSettings(); settings.setBuiltInZoomControls(false);//设置缩放 settings.setJavaScriptEnabled(true); settings.setBuiltInZoomControls(false);// 设置出现缩放工具 webView.setWebChromeClient(new WebChromeClient()); webView.setWebViewClient(new WebViewClient());
webView.loadDataWithBaseURL("网址", "数据", "text/html", "utf-8", null);
今天又进行了测试,因为后台的图片大小不一,所以导致显示还是有点问题,百度了下,在html代码上进行处理
html = "<head><style>img{max-width:100%;height:auto;}</style></head>" + html; //html代码加上图片宽度填满 webView.loadDataWithBaseURL(Utils.BaseUrl, html, "text/html", "utf-8", null);
目前可以了没发现有什么问题