How can I create the bitmap from the canvas of custom view.
getDrawingCache() is deprecated in API 28.
So now you may use following code inside your custom view
Bitmap bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
draw(canvas);
// return bitmap; -- this is the bitmap you need
If you want to use this code outside your cusom view use methods like viewInstance.getHeight()... viewInstance.draw(canvas) will draw the view on the bitmap