The problem with drawToBitmap
is as the documentation says
The resulting bitmap will be the same width and height as this view's current layout dimensions
so it will usually be the a maximum of the screen dimensions or smaller.
It's best to create a view
specifically for drawing to a bitmap and then measure and layout it out for the size bitmap you want and then play with the bitmap scale as well.
An Example in Java https://stackoverflow.com/a/60582865/2373819
You can then create the bitmap as big as the view wants to be by measuring with UNSPECIFIED
or as big as the you want it to be with EXACTLY
Update: based on comment and updated question
I think you missed the key points of the linked answer (and scale there was used to actually make the bitmap smaller)
- You need to
measure
, layout
and draw
the view as if it was being displayed on a larger resolution screen, therefore you do not want to do this to view
that you have already drawn to the screen.
- So create a new
view
(either from xml or programmatically)
measure
it to the size the view
wants to be with UNSPECIFIED
- Layout it out by calling layout
- Create bitmap to the views size
- Draw view to Bitmaps canvas instead of the screens canvas.
just ignore the bitmapCanvas.scale(scaleFactor, scaleFactor);
in the linked example.