0

So I'm using layout weights to scale parts of my layout to a certain fraction of the screen, and when I try to add an empty view for padding between elements, it causes a 0-size error on the views.

The original layout, which works before adding anything is: http://pastiebin.com/?page=p&id=4e9777a2639f4 (Sorry for the pastebins instead of pasting it here, it wouldn't format correctly because of the xml tags)

And adding this between, or before or after any of the DWIButtons cause the error: http://pastiebin.com/?page=p&id=4e9777caefc2d

I have no idea what to do here ):

EDIT 1: Here it is without the padding view added

bad layout

EDIT 2: Also, adding any other type of view doesn't mess it up. I added a TextView instead of a blank View, and it resized correctly

Nick Badal
  • 681
  • 1
  • 8
  • 26

1 Answers1

0

adding images might help us understand the situation. but i suspect the layout weight is what is messing up your layout. setting layout weight to 1 means you want the blank layout to fill the available space(most of the time the entire screen).

Ifewalter
  • 114
  • 2
  • 6
  • i said earlier, layout weights seem to be the main cause of your problems. instead of that, why not use independent pixels sizes? – Ifewalter Oct 14 '11 at 00:07
  • I cant get a picture of the padding since it doesn't work, but it should just add more blue space below, or inbetween buttons. And I have around 20 other layouts that work fine with weights until this one. – Nick Badal Oct 14 '11 at 00:15
  • @nickbadal my guess is the error you are experiencing is the entire layout gets blanked out when you insert you new "error line" no?, that is because with layout weight 1.0 as i mentioned earlier, it takes up the entire screen. this should answer your question http://stackoverflow.com/questions/4986861/android-layout-weight – Ifewalter Oct 14 '11 at 00:18
  • Nope, it causes one of my custom views to throw a "width can't be <= 0 exception". The weights on the custom views themselves should in theory prevent the smaller weight from pushing it off of the screen. – Nick Badal Oct 14 '11 at 00:58