here i have a quick question on webview.
My requirement is capture the webview and save the file in sdcard to that i used below code.
Below code for generating Bitmap from webview
Webview to Bitmap :
webview.measure(MeasureSpec.makeMeasureSpec(
MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
webview.layout(0, 0, webview.getMeasuredWidth(),
webview.getMeasuredHeight());
webview.setDrawingCacheEnabled(true);
webview.buildDrawingCache();
bitmap = Bitmap.createBitmap(webview.getMeasuredWidth(),
webview.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas bigcanvas = new Canvas(bitmap);
Paint paint = new Paint();
int iHeight = bitmap.getHeight();
bigcanvas.drawBitmap(bitmap, 0, iHeight, paint);
webview.draw(bigcanvas);
}
catch (Exception e)
{
e.printStackTrace();
}
webview.setDrawingCacheEnabled(false);
below code for to save the file in memory for that
To save as file :
File myDir = new File(Environment.getExternalStorageDirectory(), "Sample");
if (myDir.exists())
{
}
else
{
myDir.mkdir();
}
String fname = "sample" + ".png";
file1 = new File(myDir, fname);
if(bitmap!=null)
{
try
{
FileOutputStream out = new FileOutputStream(file1);
bitmap.compress(Bitmap.CompressFormat.PNG, 10, out);
out.flush();
out.close();
}
catch (Exception e)
{
e.printStackTrace();
}}
but here webview loading fine but not capturing completely in android 5.0(lollipop) as shown in below image
how can i resolve this issue? please give me suggestions or some snippet of code.
Thanks in advance..