Here's what I did in my activity to figure out the content layout of a particular view child that I knew stretched end-to-end on the screen (a webview in this case):
First, inherit from OnGlobalLayoutListener:
public class ContainerActivity extends Activity implements ViewTreeObserver.OnGlobalLayoutListener {
...
Next, implement onGlobalLayout method of listener's interface (note I do some pixel calcs that pertain to figuring out the medium-zoom dip :
@Override
public void onGlobalLayout() {
int nH = this.mWebView.getHeight();
int nW = this.mWebView.getWidth();
if (nH > 0 && nW > 0)
{
DisplayMetrics oMetrics = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(oMetrics);
nH = (nH * DisplayMetrics.DENSITY_DEFAULT) / oMetrics.densityDpi;
nW = (nW * DisplayMetrics.DENSITY_DEFAULT) / oMetrics.densityDpi;
// do something with nH and nW
this.mWebView.getViewTreeObserver().removeGlobalOnLayoutListener
( this
);
...
}
}
Finally, make sure to tell the view element (mWebView in this case) inside onCreate() that you're listening to layout events:
this.setContentView(this.mWebView = new WebView(this));
this.mWebView.getViewTreeObserver().addOnGlobalLayoutListener
( this
);
This approach works for older android versions. I believe ics+ has a layout listener for each view you can bind to, and as such, would be used in a similar way.