Skip to content

[iOS] Fix ScrollView not expanding to full width in landscape when HorizontalOptions=FillAndExpand#34469

Closed
praveenkumarkarunanithi wants to merge 2 commits intodotnet:mainfrom
praveenkumarkarunanithi:fix-20042
Closed

[iOS] Fix ScrollView not expanding to full width in landscape when HorizontalOptions=FillAndExpand#34469
praveenkumarkarunanithi wants to merge 2 commits intodotnet:mainfrom
praveenkumarkarunanithi:fix-20042

Conversation

@praveenkumarkarunanithi
Copy link
Copy Markdown
Contributor

Root Cause

During the measure pass on iOS, the ScrollView handler calculated its size as the minimum of the inner content size and the available screen constraint. In landscape, although the available width increased (for example, from portrait to a wider constraint), the inner content had already measured itself at the smaller width. As a result, the ScrollView retained that earlier measured width and did not re-evaluate whether the content intended to stretch and fill the additional space. Unlike Android, the iOS implementation did not check whether the inner content had Fill alignment (which is the default for Grid and most layouts) after measurement. Because of this missing alignment evaluation, the ScrollView would shrink to content size instead of expanding to fill the available width when requested.

Description of Change

The iOS ScrollView handler’s measure logic was updated to align with Android behavior. After computing the initial size from content measurement, it now evaluates whether the inner content has Fill horizontal alignment. If so, and if the available width constraint is finite, the ScrollView expands to match the full available constraint. If the available constraint is infinite (such as when the ScrollView is placed inside a StackLayout or another unconstrained parent), the logic safely falls back to the measured content size to avoid invalid fill calculations. The adjustment is applied before explicit size overrides, ensuring that developer-defined Width, MinimumWidth, or MaximumWidth values continue to take precedence.

Issues Fixed

Fixes #20042

Tested the behaviour in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Note

Orientation change is not supported on Windows and MacCatalyst in this scenario, so the corresponding test case was not added for those platforms.

Output Video

Before Issue Fix After Issue Fix
BeforeFix.22.mov
AfterFix.29.mov

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 13, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34469

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34469"

@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Mar 13, 2026
@vishnumenon2684 vishnumenon2684 added the community ✨ Community Contribution label Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[iOS] ScrollView stretched beyond the Border of the Screen in Landscape Orientation with HorizontalOptions="StartAndExpand"

2 participants