我試圖加載一些html代碼的webview,然後捕獲它並轉換成位圖。但是,在我設置的ImageView中可以看到的所有內容都是空白的方塊。將webview轉換爲位圖
webViewToPrint.loadDataWithBaseURL("", dataStringHtml , "text/html", "UTF-8", "");
webViewToPrint.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
Bitmap b = Bitmap.createBitmap(view.getHeight(), view.getWidth(), Config.ARGB_8888);
Canvas canvas = new Canvas(b);
view.draw(canvas);
imageView.setImageBitmap(b);
}});
我可以幫助你:http://stackoverflow.com/questions/30409630/how-to-capture-the-webview-to-bitmap-in-android-5-0 – santoXme