Convert a View into Image Android
Hello, Sometime we need to convert a view into an image to share with the world.

Here I converted a view into an image to share. But I changed the view while converting the view.
We can convert a view, viewgroup. Lets way you have designed a layout and wants the user to share this layout on social media.
I have build a method that takes a view and return bitmap. With the bitmap you can store, share, upload the converted image. Below is my method.
private Bitmap viewToImage(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;
}
That's it, You are all set for the have fun with the bitmap.
**NB: If you want to add some other view only on the bitmap then you need to design accordingly and make them visible and just before calling this method make those views visible and after converting image hide them again.