Skip to content

Commit

Permalink
fix(android): Invoke .forceLayout() only when appropriate.
Browse files Browse the repository at this point in the history
We must do this because we're using the Mewasure Spec "`AtMost`" instead of "`Exactly`". That was causing the reported bug.

Fix #2879
  • Loading branch information
carldebilly committed Mar 30, 2020
1 parent c4dd713 commit c4d26e3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Uno.UI/UI/Xaml/Controls/Layouter/Layouter.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,20 @@ protected Size MeasureChildOverride(View view, Size slotSize)
var widthSpec = ViewHelper.SpecFromLogicalSize(slotSize.Width);
var heightSpec = ViewHelper.SpecFromLogicalSize(slotSize.Height);

view.ForceLayout(); // Bypass Android cache, to ensure the Child's Measure() is actually invoked.
var previousDesiredSize = DesiredChildSize(view);

if (previousDesiredSize.Width > slotSize.Width || previousDesiredSize.Height > slotSize.Height)
{
// Bypass Android cache, to ensure the Child's Measure() is actually invoked.
view.ForceLayout();

// We must do this here because we're using the MeasureSpecMode.AtMost mode to force Android to
// behave like the UWP's measure phase.

// We can't use MeasureSpecMode.Exactly because native controls would take all available space.

// Issue: https://github.com/unoplatform/uno/issues/2879
}

MeasureChild(view, widthSpec, heightSpec);

Expand Down

0 comments on commit c4d26e3

Please sign in to comment.