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
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;
protected override void OnCreate(Bundle bundle)
_game = new Game1();
_view = _game.Services.GetService(typeof(View)) as View;
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;
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.
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.
I am a little lost. Which part of the code will fix my issue?
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.
Ok I don’t have my laptop right now, but my problem is exactly this right here:
I have a project that runs on Android, iOS and desktop. The same code is driving the display resolution for all platforms:
int width = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
int height = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
The game looks good on both iOS and desktop, but when running on Android devices (Galaxy S6 edge and S10), the top part of the screen are not used for rendering, it is filled with whatever color is passed to the…
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.
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.