Android文档页面上的文档显示了如何使用Media在Android5 (Lollipop)上截图:http://developer.android.com/samples/ScreenCapture/index.html
我的目标是截图,并得到它的RGBA字节数组。
你能帮我指出正确的方向吗?理想情况下,我正在寻找一个跨版本的解决方案,而媒体投影API不是:(它只有5.0
格赖斯
发布于 2015-07-10 17:06:13
如果您想从自己的程序中获取屏幕截图,您可以获得主视图并将其绘制到位图中并保存(这样,系统条就不会出现在图像上)。
我不知道有什么API能做到这一点。
类似于:
View root = findViewById(R.id.content_panel);//this need to be the root
Bitmap bmp = Bitmap.createBitmap(root.getWidth(), root.getHeight(), Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bmp);
root.onDraw(canvas);
//Compress the Bitmap bmp to a file here.https://stackoverflow.com/questions/31346455
复制相似问题