开发者

convert view to image in android

开发者 https://www.devze.com 2023-01-29 09:37 出处:网络
I\'m trying to send a chart via email in android applicat开发者_JS百科ion, how can I attach that chart to email application?Before attaching the graph to email we have to save the graph image into sto

I'm trying to send a chart via email in android applicat开发者_JS百科ion, how can I attach that chart to email application?


Before attaching the graph to email we have to save the graph image into storage, For that you just enable the cache for that view by setting setDrawingCacheEnabled(true);

Then create the bitmap Bitmap.createBitmap(View.getDrawingCache());.

we can convert the bitmap to desired image format as follows

bitmap.compress(CompressFormat.PNG, 100, new FileOutputStream(filename));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号