Xamarin将Zxing MobileBarcodeScanner添加到带有覆盖

时间:2016-04-13 09:43:33

标签: android android-fragments xamarin xamarin.android zxing

我的移动应用有3个标签,使用"ActionBar.NavigationMode = ActionBarNavigationMode.Tabs;"

其中一个标签为"public class QRFragment : Fragment",标签显示完美。 当用户触摸第二个选项卡时,我希望应用程序显示QRCode扫描框而不单击任何按钮。 使用我当前的实现,单击选项卡时,它会直接跳转到扫描视图(使用MobileBarcodeScanner),它是完整视图,选项卡已消失。 我希望标签仍然存在,但只是在屏幕中央有一个小扫描框。

当片段OnCreateView加载时,我有View view = inflater.Inflate(Resource.Layout.QRFragment, null); 然后我将视图用作CustomOverlay,但它不起作用。

        scanner.UseCustomOverlay = true;
        View view = inflater.Inflate(Resource.Layout.QRFragment, null);
        //Set our custom overlay
        scanner.CustomOverlay = view;

我已经花了超过5天的时间,有人可以帮我这个吗?

非常非常感激。

1 个答案:

答案 0 :(得分:0)

Context context;
context = this; //call in onCreate()
var zxingOverlay = LayoutInflater.FromContext(context).Inflate(Resource.Layout.zxingcustomviewnull);
scanner.UseCustomOverlay = true;
scanner.CustomOverlay = zxingOverlay;