Skip to content

Commit

Permalink
chore: [Android] Fix list layouting
Browse files Browse the repository at this point in the history
Ensure to call LayoutChild() every time, since the position may change even if measure hasn't changed (when scrolling, most obviously). Note that Android's internal layout caching logic ensures that ArrangeOverride() isn't called if not needed.
  • Loading branch information
davidjohnoliver committed Aug 18, 2021
1 parent 6187297 commit 8ea0b08
Showing 1 changed file with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,28 @@ protected Size AddViewAtOffset(View child, GeneratorDirection direction, int ext
slotSize = new Size(double.PositiveInfinity, logicalAvailableBreadth);
}

var size = TryMeasureChild(child, slotSize, viewType);

if (!child.IsInLayout)
{
UnoViewGroup.StartLayoutingFromMeasure();
}
LayoutChild(child, direction, extentOffset, breadthOffset, size);

if (!child.IsInLayout)
{
UnoViewGroup.EndLayoutingFromMeasure();
}

return size;
}

/// <summary>
/// Measure item view if needed.
/// </summary>
/// <returns>Measured size, or cached size if no measure was necessary.</returns>
private Size TryMeasureChild(View child, Size slotSize, ViewType viewType)
{
var previousAvailableSize = LayoutInformation.GetAvailableSize(child);

if (child.IsLayoutRequested || slotSize != previousAvailableSize)
Expand All @@ -910,17 +932,6 @@ protected Size AddViewAtOffset(View child, GeneratorDirection direction, int ext
size = ApplyChildStretch(size, slotSize, viewType);
}

if (!child.IsInLayout)
{
UnoViewGroup.StartLayoutingFromMeasure();
}
LayoutChild(child, direction, extentOffset, breadthOffset, size);

if (!child.IsInLayout)
{
UnoViewGroup.EndLayoutingFromMeasure();
}

return size;
}
else
Expand Down

0 comments on commit 8ea0b08

Please sign in to comment.