WebView截屏
来源:互联网 发布:js怎么判断是不是数组 编辑:程序博客网 时间:2024/06/05 04:54
WebView的截图有几种方式
(一)这种方式要求WebView必须设置setDrawingCacheEnabled(true)
/** * 这种方法要求webview要设置setDrawingCacheEnabled(true); * @return */ public Bitmap getWebViewFromCache(){ Bitmap drawingCacheBitmap = mWebView.getDrawingCache(); return drawingCacheBitmap; }
(二)这种方式在安卓4.4已经废除,因为capturePicture方法废除了
public Bitmap getWebViewCapturePicture(){ Picture picture = mWebView.capturePicture(); Bitmap bitmap = Bitmap.createBitmap(picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); mWebView.draw(canvas); return bitmap; }
(三)直接给当前页面截屏
/** * 截屏 * @return */ public Bitmap getWebViewDecorView(){ View decorView = this.getWindow().getDecorView(); Bitmap bitmap = Bitmap.createBitmap(decorView.getWidth(), decorView.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); decorView.draw(canvas); return bitmap; }
0 0
- WebView截屏
- Android Webview截屏
- android webview 截屏
- WebView
- WebView
- WebView
- webView
- webView
- webview
- webview
- WebView
- webview
- webview
- webview
- WebView
- webView
- webview
- webView
- 面试
- 关于mysql-connector-net和C#.net
- 吐槽CSDN手机验证
- Redux-form系列教程
- 【Spring】基于c3p0连接池,实现数据库加解密连接MySQL数据库
- WebView截屏
- 单链表逆转
- 开通啦
- 日期工具类TimeUnit
- 从逻辑回归到SVM
- eclipse build path功能总结
- stm32f10x_startup.s的代码
- build.prop 文件的部分参数
- 【C/C++】JAVA与C/C++ AES加密算法同步