Hello,
You can do it by WindowInsetsControllerCompat.hide()
method in the MainActivity.cs
in Android platform.
Firstly, you can request the framework not fit the content view by WindowCompat.SetDecorFitsSystemWindows(this.Window, false);
.
Then, you can create WindowInsetsControllerCompat to hide the system bars.
In the end, you need to set the SystemBarsBehavior
to BehaviorShowTransientBarsBySwipe
BehaviorShowTransientBarsBySwipe
to temporarily reveal hidden system bars with system gestures, such as swiping from the edge of the screen where the bar is hidden from. These transient system bars overlay your app’s content, might have some degree of transparency, and are automatically hidden after a short timeout.
You can refer to the following code.
public class MainActivity : MauiAppCompatActivity
{
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
WindowCompat.SetDecorFitsSystemWindows(this.Window, false);
WindowInsetsControllerCompat windowInsetsController = new WindowInsetsControllerCompat(this.Window, this.Window.DecorView);
// Hide system bars
windowInsetsController.Hide(WindowInsetsCompat.Type.SystemBars());
windowInsetsController.SystemBarsBehavior = WindowInsetsControllerCompat.BehaviorShowTransientBarsBySwipe;
}
For more information, you can refer to this Hide system bars for immersive mode document.
Best Regards, Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.