Calculating the size of a view
<p>The best way to ask this question is to provide an example, so here it is:</p>

<pre><code>&lt;ScrollView&gt;
    &lt;LinearLayout
        android:id="@+id/main"
        android:orientation="vertical"
    &gt;
        &lt;TextView
            android:id="@+id/some_text"
        /&gt;
        &lt;LinearLayout
            android:id="@+id/stretch_me"
        /&gt;
        &lt;Button
            android:id="@+id/i_can_toggle"
        /&gt;
        &lt;TextView
            android:id="@+id/toggle_me"
            android:visibility="gone"
        /&gt;
        &lt;Button
            android:id="@+id/finished"
        /&gt;
    &lt;/LinearLayout&gt;
&lt;/ScrollView&gt;
</code></pre>

<p>This seems fairly simple, but hold on ...</p>

<p>1) I would like the stretch_me layout to take all the remaining space on the screen (and I need its size so I can dynamically populate it from code)</p>

<p>2) I can't change main to RelativeLayout because I would like to toggle toggle_me between gone and visible using the i_can_toggle but need to keep strech_me size the same as before</p>

<p>3) Before changing toggle_me to visible there must be no scroll and finished button must be positioned at the bottom of the screen</p>

<p>Now I have tried many things and the most promising approach was this one with some coding (I was thinking about setting the stretch_me size from code), but I was not able to get the size of the view from my onCreate() method (screen_height - view_height = remaining space).</p>

<p>Any ideas?</p>

<p>Thanks!</p>
