Answer the question
In order to leave comments, you need to log in
How do I take the content of a fragment and convert it to a bitmap?
My problem is that I need, roughly speaking, to select photos, display them dynamically in a fragment, then, at the click of a button, save all the contents of this fragment in a bitmap, and then in pdf format
. But I don’t know how to turn to this content of the fragment, I thought that it was possible to somehow pull the canvas, but did not find a suitable method.
Answer the question
In order to leave comments, you need to log in
private Bitmap createBitmapFromView (View view) {
Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(returnedBitmap);
Drawable bgDrawable =view.getBackground();
if (bgDrawable!=null)
bgDrawable.draw(canvas);
else
canvas.drawColor(Color.WHITE);
view.draw(canvas);
return returnedBitmap;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question