I have a layout which specifies sizes of widgets in relative dimension, for example:
The View object provides method called onSizeChanged(int w, int h, int oldw, int oldh). It is called when the layout changes the size of one of its components. If you override this method then the the code in your version of this method will know the size of itself as shown in the following snippet.
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
bounds = new Rect();
this.getDrawingRect(bounds);
// bounds will now contain none zero values
}