Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HeightRequest will be ignored #191

Open
GFI-acadon opened this issue Jul 12, 2024 · 2 comments
Open

HeightRequest will be ignored #191

GFI-acadon opened this issue Jul 12, 2024 · 2 comments

Comments

@GFI-acadon
Copy link

We use CameraBarcodeReaderView like so:

<zxing:CameraBarcodeReaderView x:Name="ScanView"
                        MaximumHeightRequest="{Binding ScannerViewHeightRequest, Source={Reference SearchView}}"
                        HeightRequest="{Binding ScannerViewHeightRequest, Source={Reference SearchView}}"
                        IsDetecting="{Binding IsDetecting, Source={Reference SearchView}}"
                        IsTorchOn="{Binding IsTorchOn, Source={Reference SearchView}, FallbackValue=true}"
                        CameraLocation="Rear"
                        BarcodesDetected="ScanView_OnBarcodesDetected"
                        SizeChanged="ScanView_SizeChanged"/>

When the page is opened, the view size is respected for a brief moment, but then it jumps to 640x480. I suspect that I found the code in:

namespace ZXing.Net.Maui
{
	internal partial class CameraManager
...
				imageAnalyzer = new ImageAnalysis.Builder()
					.SetDefaultResolution(new Android.Util.Size(**640, 480**))
					.SetBackpressureStrategy(ImageAnalysis.StrategyKeepOnlyLatest)
					.Build();

A possible solution could be:

		public NativePlatformCameraPreviewView CreateNativeView()
		{
			previewView = new PreviewView(Context.Context);
            **previewView.SetScaleType(PreviewView.ScaleType.FitCenter); <-- added**
            cameraExecutor = Executors.NewSingleThreadExecutor();

			return previewView;
		}

However, the size remains the same, and we get black areas on the sides (which is acceptable for now).

@czuck
Copy link

czuck commented Jul 18, 2024

Having a similar issue. In the Forms version the BarcodeReader was displayed in the upper half of my view and the previous results was in the bottom half. With the MAUI version the reader takes up about 5/7 of the view on Android and I can't resize it. The zxing CameraView has the same sizing issue on Android. I can resize the barcode reader on iOS, and I can resize the CommunityToolkit Camera View on Android.

@czuck
Copy link

czuck commented Jul 19, 2024

My workaround is to set the ZIndex of the CameraBarCodeReaderView to 0, then I can see the other elements on the page.

sventropy added a commit to vensas/ZXing.Net.Maui that referenced this issue Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants