以活动的截图编程 [英] Taking screenshot of activity programatically

查看:145
本文介绍了以活动的截图编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是采取截屏活动,并分享社交网站。

My requirement is to take the screen shot of an activity and share in social networking sites.

我的问题是,该活动包含一个可滚动视图(自定义的FrameLayout),我需要得到完整的滚动视图的快照(<$ C $的形象C>滚动视图尺寸大于屏幕边界大)。

My problem is that, the activity contains a scrollable view (custom FrameLayout), and I need to get the image of the complete scrollview in snapshot(scrollview size is larger than screen bounds).

(这实际上是由延伸框架布局作出了定制视图,滚动diagonally.I需要显示树状结构由节点和连接在该链接。树结构的高度和宽度可以比屏幕大界。我需要这整个树结构的卡店与大家共享。这正是我的要求是什么。)

(This is actually a custom view made by extending Frame layout, to scroll diagonally.I need to display a tree like structure consisting of nodes and connecting links in that. The height and width of the tree structure can be larger than screen bounds. I need to take snap shop of this whole tree structure and share. This is exactly what my requirement is.)

请指点我如何做到这一点。谢谢。

Please advice me how to do this. Thanks.

推荐答案

试试下面的。

传递滚动视图连同的宽度和高度作为参数去下面的功能。它会返回一个位图可用于共享社交网站

Pass the scroll view along with the width and height as a param to the below function. It will return a bitmap which can be used to share on social networking sites

public static Bitmap loadBitmapFromView(View v, int width, int height) {
Bitmap b = Bitmap.createBitmap(width , height, Bitmap.Config.ARGB_8888);                
Canvas c = new Canvas(b);
v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height);
v.draw(c);
return b;
}

这篇关于以活动的截图编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆