LinearLayout of a WebView and a Button.

Posted by Timmmm on Stack Overflow See other posts from Stack Overflow or by Timmmm
Published on 2010-03-25T22:11:34Z Indexed on 2010/03/25 22:13 UTC
Read the original article Hit count: 437

Filed under:
|
|
|
|

Hi, I recently struggled with an apparently simple Android layout: I wanted a WebView above a Button. It worked fine with the following parameters:

WebView:
  Height: wrap-content
  Weight: unset (by the way, what is the default?)

Button:
  Height: wrap-content
  Weight: unset

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 http://code.google.com/p/apps-for-android/source/browse/trunk/Samples/WebViewDemo/res/layout/main.xml):

WebView:
  Height: 0
  Weight: 1

Button:
  Height: wrap-content
  Weight: unset

If you change any of those, e.g. give button a weight or change the WebView 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?

© Stack Overflow or respective owner

Related posts about android

Related posts about webview