layout_wieght gives different results depending on whether or not the
width/height value set in the XML is 0 or not.

What layout_weight does is: a view is allowed to have the specified size
(e.g. wrap_content or 100dp, or 200px, or 0) and then any unused space in
the parent is distrubuted according to the weights.

The practical implicaiton of this is:

- If you want to use a fixed fraction of the parent view, then use
layout_width="0px" and layout_weight="some value". This makes the view start
out 0px width, and then take up more space.

- If you set layout_width="wrap_content", and layout_weight="some value", it
means, measure the view (wrap_content), make it that size, and then add more
space if available.

In the first case, if you have two views with equal weight, they will end up
equally sized.

In the second case, if the two views have different sizes due to
wrap_content (e.g. one is "foo", the other "Android (r) Gingerbread 3.0"),
they will end up differently sized even with equal layout_weight values.

-- Kostya

2011/6/3 Chris <crehb...@gmail.com>

> Its hard to pinpoint the exact problem, but in general if you break the
> layout up into smaller layout components (and avoid using wrap_content if
> you're looking for things to line up) it might be easier to get it right.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to