【问题标题】:How to limit auto orientation to portrait and reverse portrait如何将自动方向限制为纵向和反向纵向
【发布时间】:2020-09-19 22:00:36
【问题描述】:

只有当我将方向设置为 ScreenOrientation.FullSensor 时,应用程序才会自动倒置(反向纵向)。

但是,它也有我不想要的风景。

我尝试在方向更改时覆盖方向,但该回调不会覆盖参数,它会继续执行方向更改而不返回。

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

如何在纵向和反向纵向之间自动定位我的 xamarin 应用程序?

【问题讨论】:

标签: c# android xamarin android-sensors android-orientation


【解决方案1】:

如果你想覆盖OnConfigurationChanged,你应该在你的活动属性中添加以下属性:

ConfigurationChanges = ConfigChanges.Orientation|ConfigChanges.ScreenSize|ConfigChanges.KeyboardHidden

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多