ZXing Barcode Reader: how to make custom border around capture screen?

I want to put a custom border around the zxing capture screen (camera screen). What modification do I need to do for this? What activities and layouts do I need to change to have this effect?

+7
source share
3 answers

You do not need to edit layouts at all.

In the ViewfinderView find the onDraw method. This is the core that draws the "scanning rectangle." You can change it the way you want.

The code that actually draws the rectangle can be found here :

 // Draw the exterior (ie outside the framing rect) darkened paint.setColor(resultBitmap != null ? resultColor : maskColor); canvas.drawRect(0, 0, width, frame.top, paint); canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, paint); canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1, paint); canvas.drawRect(0, frame.bottom + 1, width, height, paint); 
+10
source

Here , as some others at SO did.

Also look here , it looked useful.

Finally, I would use this one .

+3
source

In fact, you can override the color in your own colors.xml file ie

 <color name="viewfinder_border">#00d1cf</color> 
+1
source

All Articles