Skip to content

[Android] Clamp BottomNavigationView MaxItemCount to 5 for Material3 net11.0 compatibility#34601

Merged
PureWeen merged 3 commits intonet11.0from
Resolvenet11failures
Mar 24, 2026
Merged

[Android] Clamp BottomNavigationView MaxItemCount to 5 for Material3 net11.0 compatibility#34601
PureWeen merged 3 commits intonet11.0from
Resolvenet11failures

Conversation

@Ahamed-Ali
Copy link
Copy Markdown
Contributor

@Ahamed-Ali Ahamed-Ali commented Mar 23, 2026

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!

Description of Change

On net11.0, the Material3 package (#33450) changed BottomNavigationView.MaxItemCount from 5 to 6. This caused Android Shell and TabbedPage bottom navigation rendering to change, breaking ~16 screenshot baselines on the net11.0 branch.

This PR clamps MaxItemCount back to 5 to maintain consistent behavior across .NET versions.

Code Changes

BottomNavigationViewUtils.cs:

  • Added MaxBottomNavigationItems = 5 constant
  • SetupMenu and CreateMoreBottomSheet both clamp maxBottomItems to this constant

ShellItemRenderer.cs:

  • "More" tab logic and UpdateMenuItems now clamp MaxItemCount to 5, preventing more than 5 items in the bottom navigation bar

Snapshot Updates

Updated 16 Android screenshot baselines affected by the tab layout change:

  • Shell appearance tests (tab bar colors, foreground, background, RTL)
  • TabbedPage menu item tests
  • Tab icon and visibility tests
  • Flyout icon tests
  • Navigation bar layout tests

Also updated:

  • Material3TimePicker_InitialState_VerifyVisualState (android-notch-36)
  • VerifyHybridWebViewWithShadow (ios-26)

Known Gaps

This PR does NOT update all affected snapshots. The following are known to still need baseline updates or investigation:

Root Cause

The Material3 package on net11.0 increased BottomNavigationView.MaxItemCount from 5 to 6. This changed the layout of bottom navigation tabs, causing extra space allocation and rendering differences in all tests that capture bottom navigation UI.

See: #33450

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 23, 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 -- 34601

Or

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

@Ahamed-Ali Ahamed-Ali added the community ✨ Community Contribution label Mar 23, 2026
@dotnet-policy-service dotnet-policy-service bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Mar 23, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review March 23, 2026 15:26
Copilot AI review requested due to automatic review settings March 23, 2026 15:26
@sheiksyedm
Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
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 enforces a consistent 5-item maximum for Android bottom navigation across .NET versions by clamping BottomNavigationView.MaxItemCount (notably when Material returns 6 on .NET 11), helping avoid UI/layout differences such as “More” tab behavior changes.

Changes:

  • Clamp the max bottom navigation item count to 5 in BottomNavigationViewUtils.SetupMenu.
  • Clamp the max item count to 5 when building the “More” bottom sheet in BottomNavigationViewUtils.CreateMoreBottomSheet.
  • Clamp MaxItemCount usage in ShellItemRenderer for “More” tab / menu update logic.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Controls/src/Core/Platform/Android/BottomNavigationViewUtils.cs Clamps max bottom nav items to 5 for menu setup and “More” bottom sheet creation.
src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellItemRenderer.cs Clamps _bottomView.MaxItemCount to 5 where Shell computes “More” and updates menu items.

@sheiksyedm
Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
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

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

@sheiksyedm
Copy link
Copy Markdown
Contributor

/azp run maui-pr-uitests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@Ahamed-Ali
Copy link
Copy Markdown
Contributor Author

This is for the Known Build Issues
The AOT error on maui-pr will be fixed by this #34552

#34550 (comment)

@PureWeen PureWeen changed the title Resolve .NET 11 Failures [Android] Clamp BottomNavigationView MaxItemCount to 5 for Material3 net11.0 compatibility Mar 24, 2026
@PureWeen PureWeen merged commit 31d5011 into net11.0 Mar 24, 2026
190 of 200 checks passed
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.

4 participants