Open VAdaihiep opened 8 years ago
Please can you try with the latest version of the library 2.0.1?
I tried with latest version and is true that the camera preview is being stretched. Is there a way to fix this?
@albertorusso90 Yes, i had do like below:
class QRCodeReaderViewWrapper extends ViewGroup
, add a QRCodeReaderView
inside this class.@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom)
: Calculate child (qrcodereaderview width/height), then call getChildAt(0).layout(0, 0, childWidth, childHeight);
You can read this file i do with Android Vision Lib but similar with QRReaderView: https://github.com/VAdaihiep/FitCropAndroidVision/blob/master/app/src/main/java/vn/vadaihiep/fitcropandroidvision/camera/CameraSourcePreview.java
I'm using the QRCodeReaderView in the upper half of a fragment. And i've got the same problem with the stretched preview. And I don't get @VAdaihiep comment... Did anyone solved this?
Camera resolution is chosen based on View dimensions, so that's why the preview is stretched. One thing you can do while I try to find a solution is to partially hide a QRCodeReaderView with other views just to get that effect. For example, you can overlap your full-screen QRCodeReaderView with a half-size empty View or other components.
Thank you for this simple workaround :) I included this and for now, it's okay. But it would be great, if you could comment on this issue when you have found a solution.
@dlazaro66 Unless I'm missing something, but putting a overlap view on top doesn't seem to solve the problem. If the QR code is at the bottom of the screen even the user doesn't see it in preview it still gets read by QRCodeReaderView. That's kinda confusing to users. How did you solve this problem?
@yongsunCN I didn't solve it, It's just a workaround playing with the position of the views
@dlazaro66 Any update on this issue? My preview is also stretched when rotating the phone to landscape mode.
any updates regarding the stretch issue?
@mlostekk I have a demo but with Google Vision, not ZXing, you can try it here: https://github.com/VAdaihiep/FitCropAndroidVision
I also met this issue but i change the code in the class of CameraConfigurationManager like this:
if (cwNeededRotation == 90||cwNeededRotation==270) { //portrait resolution = new Point(width, height); } else { //0 180 resolution = new Point(height, width); }
i solved my problem by this way (my QrCodeReaderView show normal ,my QrCodeReaderView is full_screen)even if i dont know why do this.
@dlazaro66 I also met this issue but i change the code in the class of CameraConfigurationManager like this: if (cwNeededRotation == 90||cwNeededRotation==270) { //portrait resolution = new Point(width, height); } else { //0 180 resolution = new Point(height, width); } i solved my problem by this way (my QrCodeReaderView show normal ,my QrCodeReaderView is full_screen)even if i dont know why do this.
as someone suggested somewhere else, you can easily fix it like this:
if (barcodeCapture.getView()!=null) {
CameraSourcePreview cameraSourcePreview = barcodeCapture.getView().findViewById(R.id.preview);
cameraSourcePreview.post(cameraSourcePreview::requestLayout);
}
I set width and height of QRCodeReaderView 300dp, the issue is: Camera preview is stretch, like fitXY scaleType in ImageView (If you need, i will capture screen)
Please help me to make camera preview keep aspect ratio when fix QRCodeReaderView width height. Thanks in advance.