I want to know: What is android:weightSum and layout weight, and how do they work?
The documentation says it best and includes an example, (highlighting mine).
android:weightSum
Defines the maximum weight sum. If unspecified, the sum is computed by adding the layout_weight of all of the children. This can be used for instance to give a single child 50% of the total available space by giving it a layout_weight of 0.5 and setting the weightSum to 1.0.
So to correct superM's example, suppose you have a LinearLayout
with horizontal orientation that contains two ImageViews
and a TextView
with. You define the TextView
to have a fixed size, and you'd like the two ImageViews
to take up the remaining space equally.
To accomplish this, you would apply layout_weight
1 to each ImageView
, none on the TextView
, and a weightSum
of 2.0 on the LinearLayout
.