From f5043eea30f9928acd573f738b8294f16ab019b1 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 13 May 2020 22:11:33 +0200 Subject: [PATCH] fixed status bar and display offset in android demo --- Demos.Android/Activity1.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Demos.Android/Activity1.cs b/Demos.Android/Activity1.cs index 4d7e997..6ee2b0e 100644 --- a/Demos.Android/Activity1.cs +++ b/Demos.Android/Activity1.cs @@ -23,6 +23,9 @@ namespace Demos.Android { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); + // render under notches + if (Build.VERSION.SdkInt >= BuildVersionCodes.P) + this.Window.Attributes.LayoutInDisplayCutoutMode = LayoutInDisplayCutoutMode.ShortEdges; TextInputWrapper.Current = new TextInputWrapper.Mobile(); this.game = new GameImpl(); @@ -30,11 +33,18 @@ namespace Demos.Android { this.game.GraphicsDeviceManager.ResetWidthAndHeight(this.game.Window); // disable mouse handling for android to make emulator behavior more coherent this.game.OnLoadContent += game => game.InputHandler.HandleMouse = false; + // set the game to fullscreen to cause the status bar to be hidden + this.game.GraphicsDeviceManager.IsFullScreen = true; this.view = this.game.Services.GetService(typeof(View)) as View; - this.SetContentView(this.view); this.game.Run(); } + public override void OnWindowFocusChanged(bool hasFocus) { + base.OnWindowFocusChanged(hasFocus); + // hide the status bar + this.view.SystemUiVisibility = (StatusBarVisibility) (SystemUiFlags.LayoutStable | SystemUiFlags.LayoutHideNavigation | SystemUiFlags.LayoutFullscreen | SystemUiFlags.HideNavigation | SystemUiFlags.Fullscreen | SystemUiFlags.ImmersiveSticky); + } + } } \ No newline at end of file