View.post(), and when Runnables are executed
<p>My original problem was needing to know the height and width of my root <code>View</code> so that I could make programmatic layout changes. For my purposes, I don't necessarily need to determine this information during <code>onCreate()</code>; it's quite sufficient for me to programmatically add my child <code>View</code>s after layout of the root has completed, so therefore I'm happy to use <code>onWindowFocusChanged()</code> as a hook to determine when calling the root <code>View</code>'s <code>getWidth()</code> and <code>getHeight()</code> will return valid results. </p>

<p>However, I see quite a few people have asked how to determine the root <code>View</code>'s size during <code>onCreate()</code>. I'm guessing people want to do this for better user experience - perhaps so that users don't see the layout being built in stages (if anyone can clarify the reasons, I'd appreciate it). Now, the answer I have commonly seen given to this, such as the one <a href="http://stackoverflow.com/questions/3602026/linearlayout-height-in-oncreate-is-0">here</a>, is to post a <code>Runnable</code> to the root <code>View</code> within <code>onCreate()</code>. Inside that <code>Runnable</code> we perform the <code>getWidth()</code>, etc. The reason why this works is because, apparently, <code>Runnable</code> objects posted to a <code>View</code> are executed when the <code>View</code> has layout and / or is attached to the window. </p>

<p>This brings me to my question. In the API documentation for <code>View</code>, it doesn't seem to describe this behavior. So, can anyone tell me where it is defined and documented? Or, is it a matter of inspecting the source? Is it an absolutely and rigidly defined feature that <code>Runnables</code> will stay in a <code>View</code>'s queue and only be handled at a certain point after the layout process?</p>

<p><strong>Further clarification:</strong> On reading Kerry's answer and thinking it over a bit more, my basic question can be clarified as follows: In the answer given <a href="http://stackoverflow.com/questions/3602026/linearlayout-height-in-oncreate-is-0">here</a> and also in this <a href="http://www.codeproject.com/Tips/313848/Get-actual-screen-size-for-the-application-layout" rel="nofollow">CodeProject entry</a>, I understand that we get around the problem of the root <code>View's</code> dimensions not being available during the <code>onCreate()</code> by posting a <code>Runnable</code> to the <code>View</code>. As Kerry points out, the guarantee is that this message <code>Runnable</code> cannot be executed until <code>onCreate()</code> has executed. I understand that layout occurs some point after <code>onCreate</code>, but I still can't grasp at the moment why this <code>Runnable</code> should execute when the <code>View</code>'s dimensions are known. </p>
