[英]android webview full page screen capture
我正在尝试将webview的整个页面内容捕获为android中的屏幕快照(位图),但没有运气。 测试了stackoverflow和其他站点中建议的许多解决方案。 请帮忙。
Bitmap bitmap = Bitmap.createBitmap(webView.getWidth(), webView.getContentHeight(), Bitmap.Config.ARGB_4444);
webView.draw(new Canvas(bitmap));
您可以尝试以下方法:
WebView w ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
w = new WebView(this);
w.setWebViewClient(new WebViewClient()
{
public void onPageFinished(WebView view, String url)
{
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/yahoo.jpg" );
if ( fos != null )
{
b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.close();
}
}
catch( Exception e )
{
}
}
});
setContentView(w);
w.loadUrl("http://search.yahoo.com/search?p=android");
}
我从听到的声音中找到了这个。 你以这种方式尝试过吗
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.