-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
When using ViewCompat.SetOnApplyWindowInsetsListener for Edge-to-Edge support on Android 15+ devices, CollectionView items inside a NavigationPage receive incorrect padding after rotating the screen from landscape to portrait orientation.
The padding size matches the DisplayCutout insets value (e.g., 118px). When scrolling, items that are redrawn after going off-screen display correctly without the extra padding.
The WindowInsetsHandler sets correct padding values (confirmed via debug logs), and returns WindowInsetsCompat.Consumed, but the CollectionView items still receive incorrect padding.
Steps to Reproduce
- Create a MAUI app targeting Android 15+ (API 35+)
- Use NavigationPage as the root page structure
- Add a CollectionView with multiple items to a page
- In MainActivity.OnCreate, add the following Edge-to-Edge setup
if (Build.VERSION.SdkInt >= BuildVersionCodes.VanillaIceCream)
{
WindowCompat.SetDecorFitsSystemWindows(Window, false);
ViewCompat.SetOnApplyWindowInsetsListener(Window.DecorView, new WindowInsetsHandler());
}
5.Implement WindowInsetsHandler
csharppublic class WindowInsetsHandler : Java.Lang.Object, IOnApplyWindowInsetsListener
{
public WindowInsetsCompat OnApplyWindowInsets(View view, WindowInsetsCompat insets)
{
var systemBars = insets.GetInsets(WindowInsetsCompat.Type.SystemBars());
view.SetPadding(systemBars.Left, systemBars.Top, systemBars.Right, systemBars.Bottom);
return WindowInsetsCompat.Consumed;
}
}
- Run the app on an Android 15+ device with a display cutout (notch)
- Rotate the device: Portrait → Landscape → Portrait
- Expected: CollectionView items display correctly without extra padding
- Actual: CollectionView items have incorrect padding on the right side (matching DisplayCutout insets size)
Version with bug
10.0.1 (MAUI 10.0.11)
Is this a regression from previous behavior?
Yes, this worked in .NET 9 / MAUI 9
Last version that worked well
9.0.x (MAUI 9)
Affected platforms
Android
Affected platform versions
Android 15 (API 35) and above
Did you find any workaround?
Removing ViewCompat.SetOnApplyWindowInsetsListener prevents this issue, but then Edge-to-Edge support cannot be properly implemented for Android 15+ devices.
Relevant log output
[WindowInsets] Rotation: Rotation90
[WindowInsets] SystemBars: L=0, T=74, R=0, B=63
[WindowInsets] DisplayCutout: L=118, T=0, R=0, B=0
[WindowInsets] Applied Padding: L=118, T=74, R=0, B=63
[WindowInsets] Rotation: Rotation0
[WindowInsets] SystemBars: L=0, T=118, R=0, B=63
[WindowInsets] DisplayCutout: L=0, T=118, R=0, B=0
[WindowInsets] Applied Padding: L=0, T=118, R=0, B=63
Note: Even though Applied Padding: L=0 is set correctly when returning to portrait, CollectionView items still show incorrect padding.