1

I'm trying to take a screenshot of a layout that contains several webview using this code.

LinearLayout v = LinLayList.get(0);
v.setBackgroundColor(0xFFFFFFFF);
v.setDrawingCacheEnabled(true);         
v.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
v.layout(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
v.buildDrawingCache(true);
Bitmap b = Bitmap.createBitmap(v.getDrawingCache());
v.setDrawingCacheEnabled(false);

But here's what I'm getting ( layout is above and the screenshot is below ).

enter image description here

While the textviews with "AAAAA!" appear fine in the screenshot, the webview seem to be missing.

Any ideas what might have caused it?

Thanks!

Roger Travis
  • 8,402
  • 18
  • 67
  • 94

1 Answers1

1

Web view is not a simple view, I don't sure 100% but maybe you can't take screenshot form web view in standart way. This may help you :

Capture picture from WebView

Community
  • 1
  • 1
hsafarya
  • 1,043
  • 1
  • 10
  • 21