原
WebView web;
String url;
web.getSettings().setUseWideViewPort(true);
web.getSettings().setLoadWithOverviewMode(true);
web.getSettings().setDisplayZoomControls(false);
web.setVerticalScrollBarEnabled(false);
web.setHorizontalScrollBarEnabled(false);
web.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
String data = "<img src=\""+url+"\" />";
web.loadUrl(url);
web.loadDataWithBaseURL("",data,"text/html", "UTF-8", "");
后
WebView web;
String url;
web.setVerticalScrollBarEnabled(false);
web.setHorizontalScrollBarEnabled(false);
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setUseWideViewPort(true);
web.getSettings().setLoadWithOverviewMode(true);
String data = "<p><img src=\""+url+"\" width=\"100%\""+" height=\"100%\""+" /></p>";
web.loadUrl(url);
web.loadDataWithBaseURL("",data,"text/html", "UTF-8", "");
后 参考Showing Gravatar images in an Android app
ImageView img;
String url = "url_example";
new AsyncTask<String, Void, Bitmap>(){
protected Bitmap doInBackground(String... params) {
HttpURLConnection httpURLConnection = null;
try{
httpURLConnection = (HttpURLConnection) new URL(url).openConnection();
final InputStream is = httpURLConnection.getInputStream();
return BitmapFactory.decodeStream(is, null, new BitmapFactory.Options());
}
catch(Exception e) {
e.printStackTrace();
}
finally {
httpURLConnection.disconnect();
}
return null;
}
protected void onPostExecute(Bitmap bitmap) {
img.setImageBitmap(bitmap);
}
}.execute(grav);