1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-25 01:39:23 +01:00

fixed status bar and display offset in android demo

This commit is contained in:
Ellpeck 2020-05-13 22:11:33 +02:00
parent 3170d45bc1
commit f5043eea30

View file

@ -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);
}
}
}