Drawing a bitmap with relative layout returns illegalargumentexception

view story

http://stackoverflow.com – I am trying to create a bitmap out of a relative layout that i have created programmatically. The Realtivelayout is showing as expected but when i try to create a bitmap , it returns illegal argument exception that height and width must be > 0 this is how i am doing it Bitmap.createBitmap(saveLayout.getWidth(), saveLayout.getHeight(), Bitmap.Config.ARGB_8888); Any pointers? Edit: added this code, too: ViewTreeObserver viewTreeObserver = saveLayout.getViewTreeObserver(); if (viewTreeObserver.isAlive()) { viewTreeObserver .addOnGlobalLayoutListe (HowTos)