Determining the size of an Android view at runtime
<p>I am trying to apply an animation to a view in my Android app after my activity is created.  To do this, I need to determine the current size of the view, and then set up an animation to scale from the current size to the new size.  This part must be done at runtime, since the view scales to different sizes depending on input from the user.  My layout is defined in XML.</p>

<p>This seems like an easy task, and there are lots of SO questions regarding this though none which solved my problem, obviously.  So perhaps I am missing something obvious.  I get a handle to my view by:</p>

<pre><code>ImageView myView = (ImageView)getWindow().findViewById(R.id.MyViewID);
</code></pre>

<p>This works fine, but when calling <code>getWidth()</code>, <code>getHeight()</code>, <code>getMeasuredWidth()</code>, <code>getLayoutParams().width</code>, etc., they all return 0.  I have also tried manually calling <code>measure()</code> on the view followed by a call to <code>getMeasuredWidth()</code>, but that has no effect.</p>

<p>I have tried calling these methods and inspecting the object in the debugger in my activity's <code>onCreate()</code> and in <code>onPostCreate()</code>.  How can I figure out the exact dimensions of this view at runtime?</p>
