使用Xamarin.android应用程序Zxing库扫描时,将屏幕方向锁定为纵向。

Sam*_* Ra 3 c# android visual-studio zxing xamarin

我已经看到可以在相机配置管理器中完成此操作,但不确定在哪里可以找到该文件???

我已经添加:

          <activity android:name="MainActivity"

          android:configChanges="keyboardHidden|orientation" 

          android:screenOrientation="portrait"/>
Run Code Online (Sandbox Code Playgroud)

现在,mainactivity已锁定在人像上,但是从内部活动中运行zxing扫描仪时,屏幕在扫描过程中会旋转?

CDr*_*sos 5

将此添加到您的主要活动以锁定方向

[Activity (Label = "YourLabel", MainLauncher = true, ScreenOrientation = Android.Content.PM.ScreenOrientation.Landscape)]
Run Code Online (Sandbox Code Playgroud)

要使用代码更改方向,请使用以下命令:

if (scanning)
    RequestedOrientation = Android.Content.PM.ScreenOrientation.Portrait;
Run Code Online (Sandbox Code Playgroud)