title: Creating Bitmap from Webview with content offscreen Android
body: <p>I have a webview that I want to turn into a bitmap for another part of my application. </p>
  
  <p>Currently, I can get a bitmap of the portion of the webview that will be rendered onscreen, however my bitmap needs to contain all of the page's contents. </p>
  
  <p>Setting the webview's layoutParams to a larger size results in the original image loading onto a larger canvas.</p>
  
  <p>Here is my current implementation:</p>
  
  <pre><code>FrameLayout.LayoutParams tempParams= new FrameLayout.LayoutParams(2000,4000);
  _webView.setLayoutParams(tempParams);
  _webView.layout(0,0,2000,4000);
  int width = _webView.getWidth();
  int height = _webView.getHeight();
  
  _webView.postDelayed(new Runnable() {
      @Override
      public void run() {
          Bitmap bitmap = Bitmap.createBitmap(_webView.getWidth(), _webView.getHeight(), Bitmap.Config.ARGB_8888);
          Canvas canvas = new Canvas(bitmap);
          _webView.draw(canvas);
  
      }
  },100);
  </code></pre>
  
  <p>I have followed the following tutorials and they do not seem to resolve my issue.</p>
  
  <p><a href="https://stackoverflow.com/questions/10009265/rendering-android-webview-to-bitmap-html5-javascript-callback-issue">Rendering Android webview to bitmap, html5 javascript , callback issue</a></p>
  
  <p><a href="https://stackoverflow.com/questions/4633988/generate-bitmap-from-html-in-android">Generate bitmap from HTML in Android</a></p>
  
  <p>I was thinking about using a PictureListener and capturePicture() but those have been deprecated.</p>