gpt4 book ai didi

c# - Xamarin - 在表单中显示二维码

转载 作者:行者123 更新时间:2023-11-30 21:41:20 25 4
gpt4 key购买 nike

我正在用 Xamarin 编写一个应用程序来为给定的输入创建一个 QR 码。

using ZXing.Net.Mobile.Forms;

var writer = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = new EncodingOptions
{
Height = 200,
Width = 600
}
};
var bitmap = writer.Write("Hello Stack Overflow");

现在如何在我的表单上显示此条形码?

最佳答案

你应该使用ZXingBarcodeImageView

using System;
using Xamarin.Forms;
using System.Threading.Tasks;
using ZXing.Net.Mobile.Forms;

public class BarcodePage : ContentPage
{
ZXingBarcodeImageView barcode;

public BarcodePage ()
{
barcode = new ZXingBarcodeImageView {
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
AutomationId = "zxingBarcodeImageView",
};
barcode.BarcodeFormat = ZXing.BarcodeFormat.QR_CODE;
barcode.BarcodeOptions.Width = 300;
barcode.BarcodeOptions.Height = 300;
barcode.BarcodeOptions.Margin = 10;
barcode.BarcodeValue = "Hello Stack Overflow";

Content = barcode;
}
}

You can check the full sample in Github https://github.com/Redth/ZXing.Net.Mobile/blob/master/Samples/Forms/Core/BarcodePage.cs

关于c# - Xamarin - 在表单中显示二维码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43508517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com