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