i followed this link to screenshot my webview completely. It works fine. But I have an issue. The screenhot that I get from the webview contains white spaces on the top and bottom of the picture? How do I get rid of this? Kindly let me know.
This is the code that I've used for capturing from webview. IF YOU LOOK PROPERLY THERE IS WHITESPACE BOTH AT THE BOTTOM AND TOP PARTS OF THE IMAGE.
public static String saveCapturedImageToSdCard() {
Picture picture = WebViewActivity.sWebViewEx.capturePicture();
Bitmap b = Bitmap.createBitmap( picture.getWidth(),
picture.getHeight(), Bitmap.Config.ARGB_8888);
File file = null;
Canvas c = new Canvas( b );
picture.draw( c );
// FileOutputStream fos = null;
try {
file = new File(Environment.getExternalStorageDirectory()+"/"+"temp.png");
if(file != null && !file.exists())
file.createNewFile();
// write the bytes in file
FileOutputStream fos = new FileOutputStream(file);
fos = new FileOutputStream(file);
if ( fos != null )
{
b.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
}
}
catch( Exception e )
{
}
return file.getPath().toString();
}
This is the image that I get from the webview:
My XML is:
<WebView
android:id="@+id/webview"
android:layout_below="@id/linearlayout_topbuttons"
android:layout_above="@id/gallery_webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:overScrollMode="never"
android:fitsSystemWindows="true"
android:background="@android:color/transparent"
android:layout_centerInParent="true"
/>