user2705469
user2705469

Reputation: 5

Make vertical red line (android zxing barcode scanner )

I was able to change zxing barcode scanner portrait mode.

However, the red line is still showing horizontally.

How can I make the red line vertically?

It seems like I have to edit the following codes in ViewfinderView.java

 // Draw a red "laser scanner" line through the middle to show decoding is active
  paint.setColor(laserColor);
  paint.setAlpha(SCANNER_ALPHA[scannerAlpha]);
  scannerAlpha = (scannerAlpha + 1) % SCANNER_ALPHA.length;
  int middle = frame.height() / 2 + frame.top;`enter code here`
  canvas.drawRect(frame.left + 2, middle - 1, frame.right - 1, middle + 2, paint);

Can somebody help me to edit those codes?

Upvotes: 0

Views: 5442

Answers (1)

Kib
Kib

Reputation: 26

Just change the last two lines to this:

int middle = frame.width() /2 + frame.left;
canvas.drawRect(frame.middle - 1, frame.top + 1, frame.middle + 1, frame.bottom -1, paint);

In case you want the line thicker, change the last line to

canvas.drawRect(frame.middle - 2, frame.top + 1, frame.middle + 2, frame.bottom -1, paint);

Or just play around with it a bit.

Upvotes: 1

Related Questions