views:

102

answers:

3

As i have referred this site for Layout Tricks.

overthere one attribute is declared as android:layout_weight="1".

so my confusion is regarding android:layout_weight.

  1. where is the exact use of android:layout_weight ?
  2. Where should we use android:layout_weight ?

pls anybody focus their knowledge.

Thanx

+2  A: 

Have a look at this.

Asahi
ya i also found the same link and found really helpful.and exact information given
PM - Paresh Mayani
@Asahi you have given answer on my 2 questions perfectly...really thanx for such helps
PM - Paresh Mayani
+1  A: 

From what I understand of layout_weight, the closest comparison I could find is when you pass some % in HTML for the width or height of your div. In our context, the weigth seems to refer to the % of width or heigth your widget should get for itself compared to its neighbours in a given ViewGroup. You can find another exemple with more explanation here.
If you look the way they use it, it sticks exactly to the definition. They give a height of 0dip to keep the whole space free, and then uses equal weigths for the 2 widgets to make same th same height.

Sephy
+1  A: 

layout_weight is quite simply a priority to apply to a view class, the higher, the larger the control or group will be in proportion to it's mates inside that group. The default is 0, so a weight of 1 makes it twice as large as other default controls. No mystery.

Conrad B