我想实现CSS3翻页效果在安卓/ PhoneGap的应用程序。要做到这一点,我需要当前的web视图动态地保存到PNG或JPEG,以便它可以加载在翻页HTML一个div。我注意到,在Android的文档图片类,但我不知道是否可以被转换和保存。难道这通过JS来完成?任何想法?
I'm trying to implement the css3 page flip effect on a android/phonegap app. To do this, I need to dynamically save the current webview to png or jpeg so that it can be loaded to a div in the page flip html. I noticed the Picture class in android's docs but I'm not sure if that can be converted and saved. Could this be done through JS? Any ideas?
感谢
试试下面的$ C $下拍摄的WebView并保存JPG,以SD卡。
Try following code for capturing webview and saved jpg to sdcard.
webview.setWebViewClient(new WebViewClient() {
@Override
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( "/sdcard/" + "page.jpg" );
if ( fos != null ) {
b.compress(Bitmap.CompressFormat.JPEG, 90, fos );
fos.close();
}
}
catch( Exception e ) {
System.out.println("-----error--"+e);
}
}
});
webview.loadUrl("http://stackoverflow.com/questions/15351298/capturing-android-webview-image-and-saving-to-png-jpeg");
上一篇:Android的 - 动态更新的一个ArrayList项目后自定义的ListView添加自定义、项目、动态、Android
下一篇:无法访问" findViewById"在AsyncTask的无法访问、QUOT、AsyncTask、findViewById