MAUI Android 透明状态栏/导航栏(也有叫沉浸式的)

MAUI Android想做透明状态栏和导航栏,但找的代码很多都有兼容性问题,所幸看到了这篇 https://blog.csdn.net/Mr_Tony/article/details/121612215 代码不多,但嘎嘎好用

不说废话了,上代码,不好用来打我

Platforms/Android/MainActivity.cs

        protected override void OnCreate(Bundle savedInstanceState)
        {
            Google.Android.Material.Internal.EdgeToEdgeUtils.ApplyEdgeToEdge(Window, true);
            if (OperatingSystem.IsAndroidVersionAtLeast((int)BuildVersionCodes.Q))
            {
                Window.StatusBarContrastEnforced = false;
                Window.NavigationBarContrastEnforced = false;
            }

            base.OnCreate(savedInstanceState);
        }
posted @ 2024-04-21 16:19  Yu-Core  阅读(448)  评论(0编辑  收藏  举报