问题
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