View v = rootView.findViewById(R.id.layout1);
if (v != null) {
v.buildDrawingCache();
Bitmap bitmap = v.getDrawingCache();
canvas.drawBitmap(bitmap, dummyMatrix, null);
v.destroyDrawingCache();
}
我有这个代码。但是我需要对所有ListView
项进行屏幕截图,但是如果我的Listview
的项多于屏幕上的可见项,则当这些项大于可见的rect时,不会捕获此代码。
如何正确捕获我的ListView?
我创建的新工作代码
public static Bitmap getWholeListViewItemsToBitmap() {
ListView listview = MyActivity.mFocusedListView;
ListAdapter adapter = listview.getAdapter();
int itemscount = adapter.getCount();
int allitemsheight = 0;
List<Bitmap> bmps = new ArrayList<Bitmap>();
for (int i = 0; i < itemscount; i++) {
View childView = adapter.getView(i, null, listview);
childView.measure(MeasureSpec.makeMeasureSpec(listview.getWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
childView.layout(0, 0, childView.getMeasuredWidth(), childView.getMeasuredHeight());
childView.setDrawingCacheEnabled(true);
childView.buildDrawingCache();
bmps.add(childView.getDrawingCache());
allitemsheight+=childView.getMeasuredHeight();
}
Bitmap bigbitmap = Bitmap.createBitmap(listview.getMeasuredWidth(), allitemsheight, Bitmap.Config.ARGB_8888);
Canvas bigcanvas = new Canvas(bigbitmap);
Paint paint = new Paint();
int iHeight = 0;
for (int i = 0; i < bmps.size(); i++) {
Bitmap bmp = bmps.get(i);
bigcanvas.drawBitmap(bmp, 0, iHeight, paint);
iHeight+=bmp.getHeight();
bmp.recycle();
bmp=null;
}
return bigbitmap;
}
工作代码:
public static Bitmap getWholeListViewItemsToBitmap() {
ListView listview = MyActivity.mFocusedListView;
ListAdapter adapter = listview.getAdapter();
int itemscount = adapter.getCount();
int allitemsheight = 0;
List<Bitmap> bmps = new ArrayList<Bitmap>();
for (int i = 0; i < itemscount; i++) {
View childView = adapter.getView(i, null, listview);
childView.measure(MeasureSpec.makeMeasureSpec(listview.getWidth(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
childView.layout(0, 0, childView.getMeasuredWidth(), childView.getMeasuredHeight());
childView.setDrawingCacheEnabled(true);
childView.buildDrawingCache();
bmps.add(childView.getDrawingCache());
allitemsheight+=childView.getMeasuredHeight();
}
Bitmap bigbitmap = Bitmap.createBitmap(listview.getMeasuredWidth(), allitemsheight, Bitmap.Config.ARGB_8888);
Canvas bigcanvas = new Canvas(bigbitmap);
Paint paint = new Paint();
int iHeight = 0;
for (int i = 0; i < bmps.size(); i++) {
Bitmap bmp = bmps.get(i);
bigcanvas.drawBitmap(bmp, 0, iHeight, paint);
iHeight+=bmp.getHeight();
bmp.recycle();
bmp=null;
}
return bigbitmap;
}
我正在使用AlarmManager和Pending Intent调用BroadcastReceiver类。这是每天安排的。 以下是“活动”中调用的BroadCast Receiver类的代码(它是一个单独的类)。 问题陈述是,在此接收器中,我正在打开另一个应用程序,我想捕获屏幕截图并将其上传到服务器。但是窗口功能在广播接收器类中不可用,我无法实现,因为我超出了活动控制。 关键挑战: -在以下类中实
我需要在应用程序最小化时获得一个屏幕截图 这段代码是从应用程序activity的rootView中抓取的截图: 如何从显示获得截图,而不是从activity视图?
原文:Screenshots 这里你会找到一些示例图和生成它们的代码。 简单绘图 这里是一个带有文本标签的基本的绘图: 源代码 子图示例 多个轴域(例如子图)可使用subplot()命令创建: 源代码 直方图 hist()命令自动生成直方图,并返回项数或者概率: 源代码 路径示例 你可以使用matplotlib.path模块,在maplotlib中添加任意路径: 源代码 mplot3d mplot
问题内容: 我有一个名为overView的UIView: 我只想截取此视图的屏幕截图,而不是整个屏幕。并制作尺寸截图: 这是我的代码: 屏幕截图具有所需的大小,但是它需要整个视图的屏幕截图,而不仅仅是“ overView”。 问题答案: 要绘制一个视图,只需使用以下命令: 如果您想多次使用它,可能扩展可以完成这项工作: // Swift4 //旧的Swift 要解释这些参数的作用: UIGraph
问题内容: 我只需要当前视口的屏幕截图,尤其要注意滚动位置。基本上是当前Chrome驱动程序的功能。 从我所阅读的内容看来,这应该是完全可能的,但是由于某些原因,screenshot命令始终努力获取完整的文档截图。实际上,IE驱动程序会拍摄多个视口镜头,然后将它们缝合在一起。 我使用的是Ruby Webdriver,无论如何我都看不到仅截取视口的屏幕截图。可能吗? 问题答案: 在处理WebDriv
我试图在一个网页中给出的表格的屏幕截图。和我在代码中提供的相同元素xpath,但是Ashot代码正在捕获其他位置的屏幕截图。 我也尝试过其他截图代码, 但它给了我错误,我可以通过阅读这个链接来修复:https://github.com/pazone/ashot/issues/93,然后我使用下面的代码: 请帮助,因为此代码正在给我网页某些随机部分的屏幕截图。我也试图捕获其他元素,但我再次没有得到正