Full Screen on Android

Hello everyone.

I am trying to create a small game for Android using Monogame. I am having issues setting up the Immersive mode. I dd everything as it is suposed to be, but it is still not covering the whole screen.

I read somewhere that this is a problem monogame has, but I have not been able to find any solution on the Internet at all. I am using a Samsung Galaxy S22 Ultra as my testing device.

Here is my Activity.cs

namespace MobileConcept
{
[Activity(
Label = “@string/app_name”,
MainLauncher = true,
Icon = “@drawable/icon”,
AlwaysRetainTaskState = true,
LaunchMode = LaunchMode.SingleInstance,
ScreenOrientation = ScreenOrientation.Portrait,
ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.Keyboard | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize | ConfigChanges.ScreenLayout | ConfigChanges.UiMode | ConfigChanges.SmallestScreenSize
)]
public class Activity1 : AndroidGameActivity
{
private Game1 _game;
private View _view;

    [System.Obsolete]
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        _game = new Game1();
        _view = _game.Services.GetService(typeof(View)) as View;
        
        SetContentView(_view);
        SetFullScreen();
        _game.Run();

    }

    [System.Obsolete]
    public void SetFullScreen()
    {
        var uiOptions = (int)Window.DecorView.SystemUiVisibility;
        uiOptions |= (int)SystemUiFlags.LowProfile;
        uiOptions |= (int)SystemUiFlags.Fullscreen;
        uiOptions |= (int)SystemUiFlags.HideNavigation;
        uiOptions |= (int)SystemUiFlags.ImmersiveSticky;

        Window.DecorView.SystemUiVisibility = (StatusBarVisibility)uiOptions;
        //Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
        this.Immersive = true;
    }
}

}

Everything seems to be fine, the immersive mode is indeed activated because it hides the navigation bar and so, but it is still not covering the whole screen when I print everything.

Is there any other work around or permanent solution for this?

Thanks in advance.

1 Like

I had to add this code recently for the camera cutoff.

Fullscreen in android is messy. There are 3 or 4 (or 5 …?) Diferent apis and properties that control the keyboard/status bar/viewsize and everything in between.

2 Likes

I am a little lost. Which part of the code will fix my issue?

Thanks!

if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.P)
            {
                // Enable drawing over the camera cutoff.
             Window.Attributes.LayoutInDisplayCutoutMode |= Android.Views.LayoutInDisplayCutoutMode.ShortEdges;
            }

Call this in OnCreate().
We still don’t know if that is your issue.
A screenshot will be helpful.

1 Like

Ok I don’t have my laptop right now, but my problem is exactly this right here:

I tried using the solution some of the users provided in the comments, but it still does not work.

Apparently the viewport is not set up correctly or something.

I will post the screenshot as soons as possible.

I really appreciate your help.

Also, this image can explain my problem a little bit. You see how the image is printed on the screen but it doe snot cover the whole screen? That is exactly my issue.

For some reason, there is a region of the screen that just shows the default color you using with GraphicsDevice.Clear();

Even if Iprint a imagen on the 0,0 coordinates, it would not print at the exact 0,0 of the screen.

oh, I forgot about this thing. :wink:
It’s been years since I got this fixes in my fork.

Ok, does yhis works exactly like Monogame? As in same syntax and libraries?

Also, do I need to change anything on my code for that to work using Kni?

It a reimplementation of Xna API. Some of the things that MonoGame added might have been change or removed. The changelog has details on all the changes.

I tested it, and it is working great! Thank you so much for this recommendation, I will read more about it.

Actually, my problem is not totally solved yet. Even with the ShortEdges activated, it won’t let me print above the camera cut off.

You can see there is a white bar on the top, which i did not mean to print, its supposed to be all blue.

Honestly, I can work with this, keeping the settings to default instead of ShortEdges, but if you have a fix for this as well I appreciate it

Thank you so much for your time and patience.

Check also if you are setting graphics.IsFullscreen = true;
inside your Game1 constructor.

I am, it is actually set to true by default with the KNI template.

Try and move the Window.Attributes.LayoutInDisplayCutoutMode and your SetFullscreen method before new Games1().

Also try it without your SetFullscreen method.

1 Like

Thank you very much nkast. You’re awesome and you have my respect. For the life of me I could not find Window.Attributes.LayoutInDisplayCutoutMode |= Android.Views.LayoutInDisplayCutoutMode.ShortEdges; anywhere. Google ended up leading me here of all places even though my current game isn’t using the MG framework. Thank youi.

1 Like