如何在Android中捕获活动的完整屏幕截图?
在我的应用程序中,我只能捕获可见区域,但滚动区域不会显示在捕获的图像中。为此我做了如何在Android中捕获活动的完整屏幕截图?,android,android-layout,android-intent,android-activity,Android,Android Layout,Android Intent,Android Activity,在我的应用程序中,我只能捕获可见区域,但滚动区域不会显示在捕获的图像中。为此我做了 private void saveBitmap(Bitmap bitmap) { shopPath = new File(Environment.getExternalStorageDirectory() + "/Shopping_List.png"); FileOutputStream fos; try { fos = new FileOutputStream(shopP
private void saveBitmap(Bitmap bitmap) {
shopPath = new File(Environment.getExternalStorageDirectory() + "/Shopping_List.png");
FileOutputStream fos;
try {
fos = new FileOutputStream(shopPath);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
} catch (FileNotFoundException e) {
Log.e("FileException", e.getMessage(), e);
} catch (IOException e) {
Log.e("InputException", e.getMessage(), e);
}
}
private Bitmap takeScreenshot() {
View rootView = findViewById(android.R.id.content).getRootView();
rootView.setDrawingCacheEnabled(true);
return rootView.getDrawingCache();
}
它只拍摄可见的镜头,而不是全部活动。。在屏幕之外。。请帮帮我。。先谢谢你
view.measure(MeasureSpec.makeMeasureSpec(
MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
view.layout(0, 0, view.getMeasuredWidth(),
view.getMeasuredHeight());
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bm = Bitmap.createBitmap(view.getMeasuredWidth(),
webView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas bigcanvas = new Canvas(bm);
view.draw(bigcanvas);
我刚试过这个它很有效。。。代码不一样,但你明白了。。oyu现在可以使用位图了 可能会重复回答的问题thnxx gero,以便快速回答,但请让我知道,即使在屏幕记录之外,也可以轻松捕获整个屏幕…只需复制粘贴loadBitmapFromView方法并调用saveBitmap(loadBitmapFromView(rootView,rootView.getWidth(),rootView.getHeight()),您需要在应用程序内部执行吗?或者你需要使用adb截图?嗨,杰罗。。。什么是loadBitmapFromView?我应该创建这个方法吗?不管怎样,你的答案是向前看。。。你能说得更具体些吗?