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
                .addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {
                        saveLayout.getViewTreeObserver()
                                .removeGlobalOnLayoutListener(this);
                        viewWidth = saveLayout.getWidth();
                        viewHeight = saveLayout.getHeight();
                    }
                });
    }
In above given code onGlobalLayout() also never seemed to be called.
 
     
    