How to screenshot or snapshot a view before it's rendered?

戏子无情 提交于 2019-12-13 18:38:01

问题


I want to create an image of a view before it's rendered as a preview.

I tried Take a screenshot of a whole View but the problem is that it gives a blank bitmap because the view was not rendered at that time.

I also tried drawing cache, but it gives me a blank bitmap as well.

Is there anyway that I can create an image of a view before it's rendered on the screen?

Thanks in advance!


回答1:


Every View class support the creating of an image of its current display. The following coding shows an example for that.

# Build the Drawing Cache
view.buildDrawingCache();

# Create Bitmap
Bitmap cache = view.getDrawingCache();

# Save Bitmap
saveBitmap(cache);
view.destroyDrawingCache(); 

And it is not possible to take a screenshot of a view before it's rendered.



来源:https://stackoverflow.com/questions/22873085/how-to-screenshot-or-snapshot-a-view-before-its-rendered

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!