我有html源代码,使用WebView i加载此源代码:
WebView webView = (WebView) new WebView(getActivity());
webView = (WebView) rootView.findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
String sourceHtml = (String) this.getActivity().getIntent().getExtras().get(ROW_ID1);
webView.loadData(sourceHtml, "text/html", "UTF-8");
现在我想在BitMap或其他SdCard中保存这个WebView,我按照一些指南但从不工作,我怎么做?
答案 0 :(得分:2)
尝试使用capturePicture
功能:
Picture picture = view.capturePicture();
Bitmap b = Bitmap.createBitmap( picture.getWidth(),
picture.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas( b );
picture.draw( c );
FileOutputStream fos = null;
try {
fos = new FileOutputStream( "mnt/sdcard/screenshot.jpg" );
if ( fos != null )
{
b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.close();
}
}
catch(Exception e) {}