0

I add ZXing.Net.Mobile, ZXing.Net.Mobile.Forms to project. Here is the code:

using ZXing.Net.Mobile.Forms;
using ZXing.Net.Mobile;

namespace discountapp
{
    public partial class discountappPage : ContentPage
    {

    ZXingBarcodeImageView barcode;

    public void Handle_Clicked(object sender, System.EventArgs e)
    {
            barcode = new ZXingBarcodeImageView
             {
                 HorizontalOptions = LayoutOptions.Center,
                 VerticalOptions = LayoutOptions.Center
             };
            barcode.BarcodeFormat = ZXing.BarcodeFormat.EAN_13;
            barcode.BarcodeOptions.Height = 25;
            barcode.BarcodeOptions.Width = 75;
            barcode.BarcodeValue = "2800100028014";
            Content = barcode;
    }
    }
}

For iOS platform also add ZXing.Net.Mobile, ZXing.Net.Mobile.Forms and put some changes in AppDelegate's FinishedLaunching() implementation:

global::ZXing.Net.Mobile.Forms.iOS.Platform.Init();

For Android platform also add ZXing.Net.Mobile, ZXing.Net.Mobile.Forms and put some changes in MainActivity's OnCreate() method:

global::ZXing.Net.Mobile.Forms.Android.Platform.Init();

But after I click the button, it doesn't show Barcode, just nothing without error. Could you help, please!

Gold
  • 11
  • 1
  • 7

1 Answers1

0

This issue on the ZXing repo suggests adding

WidthRequest = 410,
HeightRequest = 410,

to ZXingBarcodeImageView which makes the barcode appear although with a bad aspect ratio.

Steve Chadbourne
  • 6,873
  • 3
  • 54
  • 82