The application only automatically goes upside down (reverse portrait) when I have the orientation set to ScreenOrientation.FullSensor
.
However, it also goes landscape which is what I don't want.
I tried to override the orientation when it changes, but that callback doesn't override the parameters and it continues to execute the orientation change without it returning .
public override void OnConfigurationChanged(Android.Content.Res.Configuration newConfig)
{
if (newConfig.Orientation == Android.Content.Res.Orientation.Landscape)
{
newConfig.Orientation = Android.Content.Res.Orientation.Portrait;
}
base.OnConfigurationChanged(newConfig);
}
How can I automatically orient my xamarin application between portrait and reverse portrait?
如果您想覆盖OnConfigurationChanged
,您应该将以下属性添加到您的活动属性中:
ConfigurationChanges = ConfigChanges.Orientation|ConfigChanges.ScreenSize|ConfigChanges.KeyboardHidden
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.