I already explained this to you :) The weight is meant to distribute the remaining empty space amongst the views. In your case, there is NO remaining empty space since all your views are "fill_parent" (i.e., they are as wide and as tall as their parent.) In this case, LinearLayout *subtracts* the overflowing space from the views. So if a child has a weight of 2 it will be shrunk twice as much as a child with a weight of 1.
On Wed, Apr 8, 2009 at 2:32 PM, Lars Dunemark <[email protected]> wrote: > > Hi everybody! > > I have played around a bit with the xml files for creating layouts and > can't explain the behaviour of layout_weight when using it in a > LinearLayout that has orientation="vertical" > > When creating a layout that is horizontal everything follows the > documentation, that a child would get more space if it's has the > highest value. > > > But the following code for vertical orientation, give more space to > the item with lowest weight. > > <?xml version="1.0" encoding="utf-8"?> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" > android:orientation="vertical" > android:layout_width="fill_parent" > android:layout_height="fill_parent"> > > <LinearLayout > android:orientation="horizontal" > android:layout_width="fill_parent" > android:layout_height="fill_parent" > android:layout_weight="3"> > > <TextView > android:text="test" > android:gravity="center_horizontal" > android:background="#aa0000" > android:layout_width="wrap_content" > android:layout_height="fill_parent" > android:layout_weight="1"/> > > </LinearLayout> > > <LinearLayout > android:orientation="horizontal" > android:layout_width="fill_parent" > android:layout_height="fill_parent" > android:layout_weight="2"> > > <TextView > android:text="test" > android:gravity="center_horizontal" > android:background="#00aa00" > android:layout_width="wrap_content" > android:layout_height="fill_parent" > android:layout_weight="1"/> > > </LinearLayout> > </LinearLayout> > > > And the question is: Is this a bug or just a feature that maybe need > more documentation? > > Best Regards > Lars Dunemark > > > > -- Romain Guy Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

