Draw elevation shadows to canvas
Asked Answered
N

1

15

I use the code below to draw a view on to a bitmap/canvas.

Bitmap bitmap = Bitmap.createBitmap(
    viewGroup.getWidth (), viewGroup.getHeight (), Bitmap.Config.ARGB_8888);
viewGroup.draw(new Canvas(bitmap));

It works great, with one small problem: it doesn't draw elevation shadows. I assume that the shadows aren't drawn in the draw method. So where are they drawn and how can I transfer them to my canvas?

Neogaea answered 10/1, 2016 at 21:52 Comment(1)
Were you able to solve somehow?Soapbox
P
7

No, shadows are drawn for Views at a lower level than that. You're using the software rendering pipeline which does not support shadows.

Polaris answered 21/6, 2016 at 12:30 Comment(3)
Is there anyway to access this 'lower level'?Neogaea
Any way around this @Chris ?Soapbox
This is a problem that has never seen a proper solution. To this day we still cannot easily convert a view to bitmap and keep its shadows, not even Pixel.copy api solved that, and the media projection option is not an option due to the consent prompt.Parka

© 2022 - 2024 — McMap. All rights reserved.