View's Weight is considered in LinearLayout's calculation only if the
View's Specification is MatchParent.
Because Weight is used to divide the parent's space to each child.
Previously, WrapContent View's Weight was also added to the sum of
Weights.
This caused the weighted View's size was calculated incorrectly.
Now, only MatchParent View's Weight is added to the sum of Weights.
As a result, the weighted View's size is calculated correctly.
float childMarginHeight = childMargin.Top + childMargin.Bottom;
bool useRemainingWidth = (childDesiredWidth == 0) && (childWeight > 0);
float childMarginHeight = childMargin.Top + childMargin.Bottom;
bool useRemainingWidth = (childDesiredWidth == 0) && (childWeight > 0);
- totalWeight += childWeight;
-
if ((childDesiredWidth == LayoutParamPolicies.MatchParent) || (useRemainingWidth))
{
if ((childDesiredWidth == LayoutParamPolicies.MatchParent) || (useRemainingWidth))
{
+ totalWeight += childWeight;
childrenMatchParentCount++;
}
childrenMatchParentCount++;
}
if (needToMeasure == true)
{
MeasureChildWithMargins(childLayout, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0));
if (needToMeasure == true)
{
MeasureChildWithMargins(childLayout, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0));
- if (childWeight > 0)
- {
- float childMeasuredWidth = childLayout.MeasuredWidth.Size.AsDecimal();
+ if ((childWeight > 0) && ((childDesiredWidth == LayoutParamPolicies.MatchParent) || (childDesiredWidth == 0)))
+ {
+ float childMeasuredWidth = childLayout.MeasuredWidth.Size.AsDecimal();
- if (childMeasuredWidth < 0)
- {
- totalWeightLength = Math.Max(totalWeightLength, totalWeightLength + childMargin.Start + childMargin.End);
- }
- else
- {
- totalWeightLength = Math.Max(totalWeightLength, totalWeightLength + childMeasuredWidth + childMargin.Start + childMargin.End);
- }
+ if (childMeasuredWidth < 0)
+ {
+ totalWeightLength = Math.Max(totalWeightLength, totalWeightLength + childMargin.Start + childMargin.End);
+ }
+ else
+ {
+ totalWeightLength = Math.Max(totalWeightLength, totalWeightLength + childMeasuredWidth + childMargin.Start + childMargin.End);
}
}
} // 2ND PHASE foreach
}
}
} // 2ND PHASE foreach
float childMarginHeight = childMargin.Top + childMargin.Bottom;
bool useRemainingHeight = (childDesiredHeight == 0) && (childWeight > 0);
float childMarginHeight = childMargin.Top + childMargin.Bottom;
bool useRemainingHeight = (childDesiredHeight == 0) && (childWeight > 0);
- totalWeight += childWeight;
-
if ((childDesiredHeight == LayoutParamPolicies.MatchParent) || (useRemainingHeight))
{
if ((childDesiredHeight == LayoutParamPolicies.MatchParent) || (useRemainingHeight))
{
+ totalWeight += childWeight;
childrenMatchParentCount++;
}
childrenMatchParentCount++;
}
MeasureChildWithMargins(childLayout, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0));
}
MeasureChildWithMargins(childLayout, widthMeasureSpec, new LayoutLength(0), heightMeasureSpec, new LayoutLength(0));
}
+ if ((childWeight > 0) && ((childDesiredHeight == LayoutParamPolicies.MatchParent) || (childDesiredHeight == 0)))
{
float childMeasuredHeight = childLayout.MeasuredHeight.Size.AsDecimal();
{
float childMeasuredHeight = childLayout.MeasuredHeight.Size.AsDecimal();