android - 如何正确设置 ZXingScannerView 的选项?

标签 android xamarin.forms xamarin.android zxing zxing.net

我在 Xamarin Forms 项目中使用 Zxing.Net.Mobile。

我在页面上调用了 ZXingScannerView,但扫描仪选项似乎不起作用。我设置了特定类型的条形码进行扫描,但它仍会扫描焦点中的所有内容。

我在 page.xaml 调用 scannerview:

 <zxing:ZXingScannerView x:Name="scanView"
                                        Grid.Row="0"
                                        Options="{Binding opts}"
                                        IsScanning="True"
                                        WidthRequest="300"
                                        HeightRequest="600"
                                        VerticalOptions="CenterAndExpand"
                                        HorizontalOptions="CenterAndExpand"/>

然后在 xaml.cs 中定义选项

public static readonly ZXing.Mobile.MobileBarcodeScanningOptions opts = new ZXing.Mobile.MobileBarcodeScanningOptions
        {
            PossibleFormats = new List<ZXing.BarcodeFormat> { ZXing.BarcodeFormat.AZTEC },
            TryHarder=true
        };

我做错了什么?

最佳答案

感谢@Jason。 答案是像这样在页面构造函数中分配 opts to scanView

public ScanPage()
        {
            InitializeComponent();
            scanView.Options = opts;
        }

关于android - 如何正确设置 ZXingScannerView 的选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65748135/

相关文章:

c# - HttpClient PostAsync 不返回

c# - TabHost 在 CreateIntentFor<> 中传递参数

mono - 尽管 servicePointManager hack,WebRequest 无法在 Xamarin.Forms 上使用 ssl

android - 多模块项目中的房间数据库

android - 使用 HTTP 服务器(不是 CCS/XMPP)在 Android GCM 应用程序中接收消息

android - 如何取消订阅广播接收器中的 RXjava 调用

c# - 错误 CS1703 : Multiple assemblies with equivalent identity have been imported - Xamarin + VSTS

Android 在输出库中包含所有依赖项

c# - 如何在 stacklayout xamarin forms pcl 上填充图像

popup - StackLayout isVisible 属性在 Xamarin Forms 中不起作用