public override void OnConfigurationChanged(Configuration newConfig)
{
//using to prevent the OnCreate from firing when rotating or screen size is changing
if (App.IsPortraitOnly)
{
RequestedOrientation = ScreenOrientation.Portrait;
newConfig.Orientation = Orientation.Portrait;
}
base.OnConfigurationChanged(newConfig);
}
1 回答
在App.Xaml.cs中有一个静态属性
在所有页面中将其设置为
false
,并在您希望它仅为纵向的页面中将其设置为true
.在Android项目的
MainActivity
中,重写方法OnConfigurationChanged
:以下是android中可用的方向值: