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

Androider picture Androider · May 2, 2011 · Viewed 14.4k times · Source

I want to put custom border around zxing capture screen (camera screen). What modification would I need to make for this? Which activity and layouts would I need to change to have this effect?

Answer

inazaruk picture inazaruk · May 14, 2011

You don't need to edit layouts at all.

In ViewfinderView find onDraw method. It's the core that draws the "scanning rectangle". You can modify it the way you want.

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

// Draw the exterior (i.e. 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);