This is a quick tip to convert or draw your view on a canvas so that you can either show it as preview or use it for any drag – drop kind of operation. Very simple and self explanatory so just posting the code


View viewToBeConverted;

Bitmap viewBitmap = Bitmap.createBitmap(viewToBeConverted.getWidth(), viewToBeConverted.getHeight(),Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(viewBitmap);

viewToBeConverted.draw(canvas);

Thats it, now you can use ‘viewBitmap’ as a normal image. You can change a few parameters to create different kinds of image, for eg when you drag your app icon on bring it on the trash can to drop it becomes red etc