Utils //记得在Activity中createView前加这句代码 /* if (Build.VERSION.SDK_INT = Build.VERSION_CODES.LOLLIPOP) { WebView.enableSlowWholeDocumentDraw(); } */ public static Bitmap capture(WebView webView) { Picture picture = webView.ca
//记得在Activity中createView前加这句代码 /* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { WebView.enableSlowWholeDocumentDraw(); } */ public static Bitmap capture(WebView webView) { Picture picture = webView.capturePicture(); int width = picture.getWidth(); int height = picture.getHeight(); Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); picture.draw(canvas); return bitmap; }