Commit 9d5e6ed
[Android] Fix NavigationBar overlapping StatusBar when NavigationBar visibility changes (#33359)
<!-- Please let the below note in for people that find this PR -->
> [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!
### Issue Details
On Android, the content area in a TabbedPage shows incorrect layout when
tabs use mixed HasNavigationBar values (some true, some false). When
switching to a tab where the NavigationBar is visible, the content area
does not properly account for the toolbar height, resulting in content
being obscured by the NavigationBar.
**Regression PR:** #27294
### Root Cause
PR #27294 introduced a default
OffscreenPageLimit value, which pre-creates tab fragments during
initialization. When switching between tabs with different
HasNavigationBar values, Android's insets system does not automatically
recalculate layout measurements because they were cached during the
pre-creation phase. While the toolbar height updates correctly via
LayoutParameters, the content area continues using stale inset
measurements.
### Description of Change
Added a call to
AndroidX.Core.View.ViewCompat.RequestApplyInsets(nativeToolbar) in
ToolbarExtensions.UpdateIsVisible after updating LayoutParameters. This
explicitly requests Android to re-dispatch window insets through the
view hierarchy, triggering remeasurement of the content area when the
toolbar visibility or height changes.
**References:**
[Android/ContentViewGroup.cs#L149](https://github.com/dotnet/maui/blob/main/src/Core/src/Platform/Android/ContentViewGroup.cs#L149)
[Android/LayoutViewGroup.cs#L166](https://github.com/dotnet/maui/blob/main/src/Core/src/Platform/Android/LayoutViewGroup.cs#L166)
[Android/MauiScrollView.cs#L303](https://github.com/dotnet/maui/blob/main/src/Core/src/Platform/Android/MauiScrollView.cs#L303)
### Tested the behavior in the following platforms
- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac
### Issues Fixed
Fixes #33340
### Screenshots
| Before Issue Fix | After Issue Fix |
|----------|----------|
| <video width="300" height="600"
src="https://github.com/user-attachments/assets/e15fe58b-a609-442c-911f-0e0f04ee8545">
| <video width="300" height="600"
src="https://github.com/user-attachments/assets/e5da01a3-c0b8-4fc1-a443-efff1409dd82">)
|
---------
Co-authored-by: Shane Neuville <[email protected]>
Co-authored-by: Jakub Florkowski <[email protected]>1 parent 61b7561 commit 9d5e6ed
File tree
7 files changed
+55
-0
lines changed- src/Controls
- src/Core/Platform/Android/Extensions
- tests
- TestCases.Android.Tests/snapshots/android
- TestCases.HostApp/Issues
- TestCases.Mac.Tests/snapshots/mac
- TestCases.WinUI.Tests/snapshots/windows
- TestCases.iOS.Tests/snapshots/ios
7 files changed
+55
-0
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
0 commit comments