diff --git a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellRenderer.cs index ba82a9af33a1..46ca471ab82d 100644 --- a/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellRenderer.cs +++ b/src/Controls/src/Core/Compatibility/Handlers/Shell/Android/ShellRenderer.cs @@ -214,9 +214,6 @@ protected virtual void OnElementSet(Shell shell) ((IShellController)shell).AddAppearanceObserver(this, shell); SwitchFragment(FragmentManager, _frameLayout, shell.CurrentItem, false); - - var rootManager = _mauiContext.GetNavigationRootManager(); - rootManager?.OnWindowContentPlatformViewCreated(); } IShellItemRenderer _currentView; diff --git a/src/Core/src/Handlers/Window/WindowHandler.Android.cs b/src/Core/src/Handlers/Window/WindowHandler.Android.cs index 3da60b24d7bd..bdb4260cbb81 100644 --- a/src/Core/src/Handlers/Window/WindowHandler.Android.cs +++ b/src/Core/src/Handlers/Window/WindowHandler.Android.cs @@ -73,7 +73,12 @@ private protected override void OnDisconnectHandler(object platformView) void OnRootViewChanged(object? sender, EventArgs e) { if (VirtualView.VisualDiagnosticsOverlay != null && _rootManager?.RootView is ViewGroup) + { + if (VirtualView.VisualDiagnosticsOverlay.IsPlatformViewInitialized) + VirtualView.VisualDiagnosticsOverlay.Deinitialize(); + VirtualView.VisualDiagnosticsOverlay.Initialize(); + } } // This is here to try and ensure symmetry with disconnect code between test handler diff --git a/src/Core/src/Platform/Android/Navigation/NavigationRootManager.cs b/src/Core/src/Platform/Android/Navigation/NavigationRootManager.cs index 8d14bed8cca4..841d7dd3a763 100644 --- a/src/Core/src/Platform/Android/Navigation/NavigationRootManager.cs +++ b/src/Core/src/Platform/Android/Navigation/NavigationRootManager.cs @@ -95,7 +95,7 @@ internal void Connect(IView view, IMauiContext? mauiContext = null) // this is called after the Window.Content is created by // the fragment. We can't just create views on demand // need to let the fragments fall - internal void OnWindowContentPlatformViewCreated() + void OnWindowContentPlatformViewCreated() { RootViewChanged?.Invoke(this, EventArgs.Empty); @@ -155,6 +155,8 @@ void SetContentView(IView? view) if (FragmentManager.IsDestroyed(context)) _viewFragment = null; + + RootViewChanged?.Invoke(this, EventArgs.Empty); } else {