「MonoGame (Xamarin.Android)で画面の向きを指定する」の版間の差分
ナビゲーションに移動
検索に移動
Administrator (トーク | 投稿記録) |
Administrator (トーク | 投稿記録) |
||
9行目: | 9行目: | ||
* 縦画面に固定したい場合は「ScreenOrientation.Portrait」を指定する。 | * 縦画面に固定したい場合は「ScreenOrientation.Portrait」を指定する。 | ||
− | <source> | + | <source lang="csharp"> |
− | + | [Activity(Label = "Game1", | |
− | + | MainLauncher = true, | |
− | + | Icon = "@drawable/icon", | |
− | + | Theme = "@style/Theme.Splash", | |
− | + | AlwaysRetainTaskState = true, | |
− | + | LaunchMode = LaunchMode.SingleInstance, | |
− | + | ScreenOrientation = ScreenOrientation.Portrait, | |
− | + | ConfigurationChanges = ConfigChanges.Orientation | | |
− | + | ConfigChanges.KeyboardHidden | | |
− | + | ConfigChanges.Keyboard | | |
− | + | ConfigChanges.ScreenSize)] | |
− | + | public class GameActivity : AndroidGameActivity | |
− | + | { | |
− | + | } | |
</source> | </source> | ||
2021年4月20日 (火) 07:17時点における最新版
MonoGame (Xamarin.Android)プロジェクトを新規作成すると必ずエントリポイントとなるActivityクラスが作られる。
このActivityクラスの「ScreenOrientation属性」を変更する。
基本的には至って普通のXamarin.Androidでの方法と同じである。
- 初期値は「ScreenOrientation.FullUser」となっておりスマホの回転にあわせグルグル回る。
- 横画面に固定したい場合は「ScreenOrientation.Landscape」を指定する。
- 縦画面に固定したい場合は「ScreenOrientation.Portrait」を指定する。
[Activity(Label = "Game1",
MainLauncher = true,
Icon = "@drawable/icon",
Theme = "@style/Theme.Splash",
AlwaysRetainTaskState = true,
LaunchMode = LaunchMode.SingleInstance,
ScreenOrientation = ScreenOrientation.Portrait,
ConfigurationChanges = ConfigChanges.Orientation |
ConfigChanges.KeyboardHidden |
ConfigChanges.Keyboard |
ConfigChanges.ScreenSize)]
public class GameActivity : AndroidGameActivity
{
}