Xamarin Forms: Using the ScanView as a Control Instead of a Page
You might want to pack additional controls like buttons or views along with the Anyline ScanView in your scan Activity. In this case you would have to use the Anyline ScanView as a custom control instead of a page.
You can easily configure this by using ViewRenderer instead of PageRenderer as shown in the examples below.
Code Snippet for Android
using System;
using Android.App;
using Android.Content;
using Android.Views;
using IO.Anyline.Plugin;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(MyBarcodeScannerView), typeof(MyBarcodeScannerViewRenderer))]
namespace Anyline.Droid
{
public class MyBarcodeScannerViewRenderer : ViewRenderer, IScanResultListener
{
private Android.Views.View view;
private ScanView scanView;
public MyBarcodeScannerViewRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> args)
{
base.OnElementChanged(args);
if (args.OldElement != null || Element == null)
{
return;
}
InitializeAnyline();
}
...
Code Snippet for iOS
using Xamarin.Forms.Platform.iOS;
using AnylineXamarinSDK.iOS;
using CoreGraphics;
using Foundation;
using System;
using UIKit;
using Xamarin.Forms;
[assembly: ExportRenderer(typeof(MyBarcodeScannerView), typeof(MyBarcodeScannerViewRenderer))]
namespace Anyline.iOS
{
public class MyBarcodeScannerViewRenderer : ViewRenderer
{
private bool initialized;
private ALScanView _scanView;
ScanResultDelegate _resultDelegate;
protected override void OnElementChanged(ElementChangedEventArgs<View> args)
{
base.OnElementChanged(args);
if (args.OldElement != null || Element == null)
{
return;
}
InitializeAnyline(this);
}
...
Related content
Android - Internet Permission
Android - Internet Permission
Read with this
Running ARM Apps On The Android Emulator
Running ARM Apps On The Android Emulator
Read with this
Play Feature Delivery - Android
Play Feature Delivery - Android
Read with this
Configuring custom files .any and .ale in Android
Configuring custom files .any and .ale in Android
Read with this
Image Storage: Cordova.Android & React-Native.Android
Image Storage: Cordova.Android & React-Native.Android
Read with this