title: LinearLayout of a WebView and a Button
body: <p>I recently struggled with an apparently simple Android layout: I wanted a <code>WebView</code> above a <code>Button</code>. It worked fine with the following parameters:</p>
  
  <pre><code>WebView:
    Height: wrap-content
    Weight: unset (by the way, what is the default?)
  
  Button:
    Height: wrap-content
    Weight: unset
  </code></pre>
  
  <p>However if the web page became too big it spilled out over the button. I tried various combinations of weights and heights, and all except one either completely hide the button, or partially cover it. This is the one that works (copied from <a href="http://code.google.com/p/apps-for-android/source/browse/trunk/Samples/WebViewDemo/res/layout/main.xml" rel="noreferrer">http://code.google.com/p/apps-for-android/source/browse/trunk/Samples/WebViewDemo/res/layout/main.xml</a>):</p>
  
  <pre><code>WebView:
    Height: 0
    Weight: 1
  
  Button:
    Height: wrap-content
    Weight: unset
  </code></pre>
  
  <p>If you change any of those, e.g. give button a weight or change the <code>WebView</code> height to wrap-content then it doesn't work. My question is: Why? Can someone please explain what on Earth the android layout system is thinking?</p>