Skip to content

Instantly share code, notes, and snippets.

@PiotrPrus
Created September 13, 2019 13:56
Show Gist options
  • Save PiotrPrus/d0bd81ea5199c73a5a8afa9856b302ba to your computer and use it in GitHub Desktop.
Save PiotrPrus/d0bd81ea5199c73a5a8afa9856b302ba to your computer and use it in GitHub Desktop.
private fun takeScreenshot() {
val fullScreen = requireActivity().window.decorView.rootView
bitmapBackground = Bitmap.createBitmap(fullScreen.width, fullScreen.height, Bitmap.Config.ARGB_8888)
canvasFullscreen = Canvas(bitmapBackground)
fullScreen.draw(canvasFullscreen)
bitmapBackgroundDrawable = BitmapDrawable(resources, bitmapBackground)
requireActivity().window.setBackgroundDrawable(bitmapBackgroundDrawable)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment