Skip to content

Commit

Permalink
fix(android): Changed the logic of previous commit.
Browse files Browse the repository at this point in the history
The goal is to prevent Android from caching when the measurement is _Infinite_ like in a `<StackPanel>`.
  • Loading branch information
carldebilly committed Mar 30, 2020
1 parent c4d26e3 commit 6f25d6a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Uno.UI/UI/Xaml/Controls/Layouter/Layouter.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,13 @@ protected Size MeasureChildOverride(View view, Size slotSize)
var widthSpec = ViewHelper.SpecFromLogicalSize(slotSize.Width);
var heightSpec = ViewHelper.SpecFromLogicalSize(slotSize.Height);

var previousDesiredSize = DesiredChildSize(view);

if (previousDesiredSize.Width > slotSize.Width || previousDesiredSize.Height > slotSize.Height)
if (double.IsPositiveInfinity(slotSize.Width) || double.IsPositiveInfinity(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.
// This could occur when one of the dimension is _Infinite_: Android will cache the
// value, which is not something we want. Specially when the container is a <StackPanel>.

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

0 comments on commit 6f25d6a

Please sign in to comment.