[Android] Clamp BottomNavigationView MaxItemCount to 5 for Material3 net11.0 compatibility#34601
Merged
[Android] Clamp BottomNavigationView MaxItemCount to 5 for Material3 net11.0 compatibility#34601
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34601Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34601" |
Contributor
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
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
MaxItemCountusage inShellItemRendererfor “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. |
src/Controls/src/Core/Platform/Android/BottomNavigationViewUtils.cs
Outdated
Show resolved
Hide resolved
src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellItemRenderer.cs
Outdated
Show resolved
Hide resolved
This was referenced Mar 23, 2026
Open
9 tasks
Contributor
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
src/Controls/src/Core/Platform/Android/BottomNavigationViewUtils.cs
Outdated
Show resolved
Hide resolved
Contributor
|
/azp run maui-pr-uitests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
This is for the Known Build Issues |
PureWeen
approved these changes
Mar 24, 2026
This was referenced Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.MaxItemCountfrom 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
MaxItemCountback to 5 to maintain consistent behavior across .NET versions.Code Changes
BottomNavigationViewUtils.cs:MaxBottomNavigationItems = 5constantSetupMenuandCreateMoreBottomSheetboth clampmaxBottomItemsto this constantShellItemRenderer.cs:UpdateMenuItemsnow clampMaxItemCountto 5, preventing more than 5 items in the bottom navigation barSnapshot Updates
Updated 16 Android screenshot baselines affected by the tab layout change:
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:
Issue18896Test- confirmed 5.74% screenshot diff in the bottom nav area (same root cause, missing baseline update)Root Cause
The Material3 package on net11.0 increased
BottomNavigationView.MaxItemCountfrom 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