Skip to content

Conversation

@BagavathiPerumal
Copy link
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Root cause

The issue arises because, in .NET MAUI on Android, when a ContentView is placed inside Shell.FlyoutContent with FlyoutBehavior values set as Flyout, the Android layout system does not fully measure and lay out the flyout content at the appropriate time. As a result, the OnSizeAllocated method receives zero values for width and height, and OnFlyoutViewLayoutChanging() is triggered before the view is fully measured. This prevents the correct dimensions from being propagated, so the layout system does not update the content size as expected.

Description of Issue Fix

The fix involves updating the ContentView frame inside the OnFlyoutViewLayoutChanging() method after the view has been measured, ensuring that the correct width and height are applied to the content, allowing the layout system to update the content size properly and display the content as expected.

Tested the behavior in the following platforms.

  • Windows
  • Mac
  • iOS
  • Android

Issues Fixed

Fixes #22045

Output

Before Issue Fix After Issue Fix
BeforeFix-OnSizeAllocated.mov
AfterFix-OnSizeAllocated.mov

…awerOpened event and updating Content so OnSizeAllocated is called with correct values when drawer opens.
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Jun 19, 2025
@dotnet-policy-service
Copy link
Contributor

Hey there @@BagavathiPerumal! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Jun 19, 2025
@BagavathiPerumal BagavathiPerumal marked this pull request as ready for review June 20, 2025 04:48
Copilot AI review requested due to automatic review settings June 20, 2025 04:48
@BagavathiPerumal BagavathiPerumal requested a review from a team as a code owner June 20, 2025 04:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue on Android where the ContentView within Shell.FlyoutContent is not being properly measured, causing OnSizeAllocated to report zero dimensions. The changes include new tests for Issue22045, updates to the HostApp to use the new flyout content, and a refactoring in ShellFlyoutTemplatedContentRenderer.cs to correctly update the content frame.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22045.cs Added automated test for validating non-zero width and height in flyout content.
src/Controls/tests/TestCases.HostApp/Issues/Issue22045.cs Updated HostApp to include the new flyout content and trigger the measurement logic.
src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellFlyoutTemplatedContentRenderer.cs Refactored code to extract frame updating into SetContentViewFrame() and added a fallback condition in OnFlyoutViewLayoutChanging to handle cases with zero frame dimensions.

Comment on lines +472 to +476
else if (_contentView?.PlatformView is not null &&
((_contentView.PlatformView.MeasuredHeight > 0 && _contentView.View.Frame.Width == 0) ||
(_contentView.PlatformView.MeasuredWidth > 0 && _contentView.View.Frame.Height == 0)))
{
SetContentViewFrame();
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compound condition checking for measured dimensions and zero frame values could be refactored into a well-named boolean variable or helper method to improve readability.

Suggested change
else if (_contentView?.PlatformView is not null &&
((_contentView.PlatformView.MeasuredHeight > 0 && _contentView.View.Frame.Width == 0) ||
(_contentView.PlatformView.MeasuredWidth > 0 && _contentView.View.Frame.Height == 0)))
{
SetContentViewFrame();
else
{
bool ShouldSetContentViewFrame = _contentView?.PlatformView is not null &&
((_contentView.PlatformView.MeasuredHeight > 0 && _contentView.View.Frame.Width == 0) ||
(_contentView.PlatformView.MeasuredWidth > 0 && _contentView.View.Frame.Height == 0));
if (ShouldSetContentViewFrame)
{
SetContentViewFrame();
}

Copilot uses AI. Check for mistakes.
@jsuarezruiz
Copy link
Contributor

/azp run MAUI-UITests-public

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen changed the base branch from main to inflight/current July 1, 2025 16:19
@PureWeen PureWeen merged commit 10bfa7b into dotnet:inflight/current Jul 1, 2025
78 checks passed
github-actions bot pushed a commit that referenced this pull request Jul 2, 2025
…l Flyout content. (#30069)

* fix-22045 - Made changes on Android ShellFlyout sizing by adding OnDrawerOpened event and updating Content so OnSizeAllocated is called with correct values when drawer opens.

* fix-22045- Set the contentview frame value when the FlyoutView layout change.

* fix-22045- Changes committed.
github-actions bot pushed a commit that referenced this pull request Jul 8, 2025
…l Flyout content. (#30069)

* fix-22045 - Made changes on Android ShellFlyout sizing by adding OnDrawerOpened event and updating Content so OnSizeAllocated is called with correct values when drawer opens.

* fix-22045- Set the contentview frame value when the FlyoutView layout change.

* fix-22045- Changes committed.
github-actions bot pushed a commit that referenced this pull request Jul 9, 2025
…l Flyout content. (#30069)

* fix-22045 - Made changes on Android ShellFlyout sizing by adding OnDrawerOpened event and updating Content so OnSizeAllocated is called with correct values when drawer opens.

* fix-22045- Set the contentview frame value when the FlyoutView layout change.

* fix-22045- Changes committed.
PureWeen pushed a commit that referenced this pull request Jul 10, 2025
…l Flyout content. (#30069)

* fix-22045 - Made changes on Android ShellFlyout sizing by adding OnDrawerOpened event and updating Content so OnSizeAllocated is called with correct values when drawer opens.

* fix-22045- Set the contentview frame value when the FlyoutView layout change.

* fix-22045- Changes committed.
PureWeen pushed a commit that referenced this pull request Jul 15, 2025
…l Flyout content. (#30069)

* fix-22045 - Made changes on Android ShellFlyout sizing by adding OnDrawerOpened event and updating Content so OnSizeAllocated is called with correct values when drawer opens.

* fix-22045- Set the contentview frame value when the FlyoutView layout change.

* fix-22045- Changes committed.
PureWeen pushed a commit that referenced this pull request Jul 17, 2025
…l Flyout content. (#30069)

* fix-22045 - Made changes on Android ShellFlyout sizing by adding OnDrawerOpened event and updating Content so OnSizeAllocated is called with correct values when drawer opens.

* fix-22045- Set the contentview frame value when the FlyoutView layout change.

* fix-22045- Changes committed.
github-actions bot pushed a commit that referenced this pull request Jul 25, 2025
…l Flyout content. (#30069)

* fix-22045 - Made changes on Android ShellFlyout sizing by adding OnDrawerOpened event and updating Content so OnSizeAllocated is called with correct values when drawer opens.

* fix-22045- Set the contentview frame value when the FlyoutView layout change.

* fix-22045- Changes committed.
github-actions bot pushed a commit that referenced this pull request Jul 31, 2025
…l Flyout content. (#30069)

* fix-22045 - Made changes on Android ShellFlyout sizing by adding OnDrawerOpened event and updating Content so OnSizeAllocated is called with correct values when drawer opens.

* fix-22045- Set the contentview frame value when the FlyoutView layout change.

* fix-22045- Changes committed.
@github-actions github-actions bot locked and limited conversation to collaborators Aug 1, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] OnSizeAllocated not reported for Android AppShell Flyout content

4 participants