/** * 抓取WEB界面的截屏 * @param WebView * @param containerWidth 截屏宽度,也就放置WebView的宽度 * @param containerHeight 截屏高度,也就放置WebView的高度 * @param baseUrl Base Url * @param content 加载的内容 */ public Bitmap catchWebScreenshot(final WebView w,final int containerWidth,final int containerHeight, final String baseUrl,final String content) { final Bitmap b = Bitmap.createBitmap(containerWidth, containerHeight, Bitmap.Config.ARGB_8888); w.post(new Runnable() { public void run() { w.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { } }); w.setPictureListener(new PictureListener() { public void onNewPicture(WebView view, Picture picture) { final Canvas c = new Canvas(b); view.draw(c); w.setPictureListener(null); } }); w.layout(0, 0, containerWidth,containerHeight); w.loadUrl(baseUrl); // w.loadDataWithBaseURL(baseUrl, content, "text/html", "UTF-8", null); }}); return b; }转自:http://sinfrancis.iteye.com/blog/1153081