0

I am taking a screenshot of my Android app in order to include it in a .pdf report.

On devices with API Level >= 26 I am using PixelCopy successfully, and I get a proper image.

For devices with API Level < 26 I am forced to use Canvas like explained here. This works OK for most of the views I use it with, but there are a couple of them that do not render correctly. For example, the following screen should be captured:

App screen

and I get:

View.Draw(canvas) screenshot

In particular, the stuff that gets badly drawn are Views created with Skia.

Is there a way to modify my existing code in order to avoid this kind of inconsistencies?

fun getBitmapFromView(view: View): Bitmap {
    val bitmap = Bitmap.createBitmap(
        view.width, view.height, Bitmap.Config.ARGB_8888
    )
    val canvas = Canvas(bitmap)
    view.draw(canvas)
    return bitmap
}
Miguel
  • 143
  • 1
  • 7

0 Answers0