WebView中页面可见部分的屏幕截图

Ale*_* Sh 2 android android-webview android-screen

在我的应用程序中是一个WebView小部件,它打开一个大页面.如何在WebView中捕获页面的可见部分?capturePicture()不适合它......

小智 8

public static Bitmap getBitmapForVisibleRegion(WebView webview) {
    Bitmap returnedBitmap = null;
    webview.setDrawingCacheEnabled(true);
    returnBitmap = Bitmap.createBitmap(webview.getDrawingCache());
    webview.setDrawingCacheEnabled(false);
    return returnedBitmap;
}
Run Code Online (Sandbox Code Playgroud)