(android开发)如何实现在code状态栏截屏 [英] (android development)how to implement screen grab with status bar in code

查看:108
本文介绍了(android开发)如何实现在code状态栏截屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使我的设备上的屏幕截图点击按钮

I want make a screen shot on my device with clicking the button

我用下面的code:

View view = getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();

不过,我发现,我捕捉到的画面没有一个状态栏。
我只是想在设备的整个屏幕。你知道我怎么能解决呢?

But I found that the picture I captured does not have a status bar. I just want the entire screen of the device. Do you know how can I fix that?

推荐答案

从上面code其不可能的,因为状态栏是不是你的活动视图的一部分。

其实,当你使用上述code捕捉图像,它只是转换你的应用程序的活动屏幕,而不是完整的设备屏幕和状态的当前工程图视图在屏幕顶部显示一个Android设备的观点你不有这样整个视图的访问(状态栏)。

Actually, When you capture image using above code, it just converts the currently drawing view of your application's activity screen, not complete device screen and statusbar appears on top of your screen is a android device's view you don't have a access of this entire view (with status bar).

如果你想获得完整的画面,然后,你必须以root设备的接入,并通过阅读Android设备的帧缓冲,然后将其转换为图像文件。然后你就可以得到完整的设备的屏幕图像(状态栏或任何其他视图)。

If you want to get complete screen image then, you have to root access of your device and by reading android device's frame-buffer and then convert it to image file. Then you can get the complete device's screen image (With statusbar or any other view).

这篇关于(android开发)如何实现在code状态栏截屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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