Fullscreen issue in MAUI

2024-02-26T13:53:38.5933333+00:00

Screenshot 2024-02-26 154409

mauiimager

my app shows a blackscreen at the bottom in emulator and in real device i have black line on top and bottom as well . I tried everything inside app in android activity .

.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,086 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,887 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 79,396 Reputation points Microsoft Vendor
    2024-02-27T03:05:58.8133333+00:00

    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.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.