我如何采取一个Android布局的屏幕截图?截图、布局、屏幕、Android

2023-09-06 11:45:37 作者:慢性毒瘾

我的问题是如何使用内置的屏幕捕获我采取截图。任何提示或样品code会大大AP preciated。

my question is how do I take a screenshot using the built in screen capture. Any hints or sample code would be greatly appreciated.

推荐答案

有两种方法可以尝试,

使用Eclipse

打开设备视图在Eclipse(窗口菜单 - >显示视图选项 - >其他,机器人 - >设备),并有右侧标有一个工具栏按钮屏幕捕获

Open the Devices view in Eclipse ( Window Menu --> Show View Option --> Other, Android --> Devices), and there's a toolbar button on the right side labeled Screen Capture

采用Android code

Using Android Code

Bitmap bitmap;
View v1 = MyView.getRootView();
v1.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);