public static GetAbsoluteOrientation ( ) : DisplayOrientation | ||
return | DisplayOrientation |
public override void BeforeInitialize() { var currentOrientation = AndroidCompatibility.GetAbsoluteOrientation(); switch (Game.Activity.Resources.Configuration.Orientation) { case Android.Content.Res.Orientation.Portrait: this._gameWindow.SetOrientation(currentOrientation == DisplayOrientation.PortraitDown ? DisplayOrientation.PortraitDown : DisplayOrientation.Portrait, false); break; default: this._gameWindow.SetOrientation(currentOrientation == DisplayOrientation.LandscapeRight ? DisplayOrientation.LandscapeRight : DisplayOrientation.LandscapeLeft, false); break; } base.BeforeInitialize(); _gameWindow.GameView.TouchEnabled = true; }
public override void OnOrientationChanged(int orientation) { if (orientation == OrientationEventListener.OrientationUnknown) { return; } // Avoid changing orientation whilst the screen is locked if (ScreenReceiver.ScreenLocked) { return; } // Check if screen orientation is locked by user: if it's locked, do not change orientation. try { if (Settings.System.GetInt(Application.Context.ContentResolver, "accelerometer_rotation") == 0) { return; } } catch (Settings.SettingNotFoundException) { // Do nothing (or log warning?). In case android API or Xamarin do not support this Android system property. } var disporientation = AndroidCompatibility.GetAbsoluteOrientation(orientation); // Only auto-rotate if target orientation is supported and not current AndroidGameWindow gameWindow = (AndroidGameWindow)Game.Instance.Window; if ((gameWindow.GetEffectiveSupportedOrientations() & disporientation) != 0 && disporientation != gameWindow.CurrentOrientation) { gameWindow.SetOrientation(disporientation, true); } }
public override void OnOrientationChanged(int orientation) { if (orientation == OrientationEventListener.OrientationUnknown) { return; } // Avoid changing orientation whilst the screen is locked if (ScreenReceiver.ScreenLocked) { return; } var disporientation = AndroidCompatibility.GetAbsoluteOrientation(orientation); // Only auto-rotate if target orientation is supported and not current AndroidGameWindow gameWindow = (AndroidGameWindow)Game.Instance.Window; if ((gameWindow.GetEffectiveSupportedOrientations() & disporientation) != 0 && disporientation != gameWindow.CurrentOrientation) { gameWindow.SetOrientation(disporientation, true); } }