How can I get notified when the layout is fully calculated? The short
answer is to attached a listener for a callback when the layout is
calculated. Here's what it looks like.
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
RelativeLayout vMain = (RelativeLayout)
this.getLayoutInflater().inflate(R.layout.main, null);
vMain.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
DisplayLayoutDimensions();
}
});
setContentView(vMain);
}
public void DisplayLayoutDimensions()
{
StringWriter sw = new StringWriter(1000);
PrintWriter out = new PrintWriter(sw);
TextView t = (TextView) findViewById(R.id.textview);
ImageView img = (ImageView) findViewById(R.id.hp67);
out.printf("\nImage Drawable\n");
out.printf("ImageView Height dp: %d\n", img.getHeight());
out.printf("ImageView Measured Height dp: %\n",
img.getMeasuredHeight());
t.setText(sw.toString());
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en