Programmatically screenshot from the parent’s View

The first necessary step is to add the appropriate permission to your AndroidManifest.xml.

The code, in one lump:

Where childView is or inherits from the View class.

Hopefully you can extrapolate from line 6 and the usage of an enum that formats other than JPEG exist and this is merely what I chose for this example code.  Likewise 80 is a value I decided on and is the desired quality of the output image; Only values from 0-100 are accepted.  (Even though png files ignore this value it is still necessary to include one and that its value falls within the 0-100 range)

Leave a Reply

Your email address will not be published. Required fields are marked *

Post Navigation