Want Larger Camera Preview Using Zbar Scanner Library In Android
I am using ZBarScannerActivity in my android app. but I am getting a small surface view on device. Actually I want full Screen camera preview to scan the QR code. Any help would be
Solution 1:
I am getting a small surface view on device. Actually I want full Screen camera preview to scan the QR code
If you are saying that camera isn't occupying the entire screen then try to change the
android:layout_width="match_parent"android:layout_height="match_parent"
of SurfaceView
and parent_layout
If it is about the scan area that you want to be in full screen, here it goes:
mScannerView = newZBarScannerView(this) { /** * this will alter the scanning area **/@Overrideprotected IViewFinder createViewFinderView(Context context) { returnnewCustomViewFinderView(context); } }; privateclassCustomViewFinderViewextendsViewFinderView { Context context; publicCustomViewFinderView(Context context) { super(context); this.context = context; setLaserEnabled(true); } @OverridepublicvoidonDraw(Canvas canvas) { super.onDraw(canvas); if (getFramingRect() != null) { updateFrameRect(); setBorderColor(ContextCompat.getColor(context, R.color.colorPrimary)); } } privatevoidupdateFrameRect() { PointviewResolution=newPoint(this.getWidth(), this.getHeight()); intheight= (int) ((float) this.getHeight()); intwidth= (int) ((float) this.getWidth()); intleftOffset= (viewResolution.x - width) / 2; inttopOffset= (viewResolution.y - height) / 2; getFramingRect().left = leftOffset; getFramingRect().top = topOffset; getFramingRect().right = leftOffset + width; getFramingRect().bottom = topOffset + height; } }
Result:
Solution 2:
I have solved this by removing following code from Camerapreview Class
if(mPreviewSize!=null) {
previewWidth=mPreviewSize.width;previewHeight=mPreviewSize.height;
}
it worked for me. It will give you full screen camera. Thank you.
Post a Comment for "Want Larger Camera Preview Using Zbar Scanner Library In Android"