Skip to content

Commit

Permalink
https://github.com/mylhyl/Android-Zxing/issues/44
Browse files Browse the repository at this point in the history
  • Loading branch information
mylhyl committed Apr 12, 2018
1 parent 69fe22e commit b3165e4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,27 @@ protected void onCreate(Bundle savedInstanceState) {
// mScannerView.toggleLight(true);

ScannerOptions.Builder builder = new ScannerOptions.Builder();
builder.setFrameSize(256, 256)
.setFrameCornerLength(22)
.setFrameCornerWidth(2)
.setFrameCornerColor(0xff06c1ae)
.setFrameCornerInside(true)
builder
.setFrameStrokeColor(Color.RED)
.setFrameStrokeWidth(1.5f)
// .setFrameSize(256, 256)
// .setFrameCornerLength(22)
// .setFrameCornerWidth(2)
// .setFrameCornerColor(0xff06c1ae)
// .setFrameCornerInside(true)

// .setLaserLineColor(0xff06c1ae)
// .setLaserLineHeight(18)

// .setLaserStyle(ScannerOptions.LaserStyle.RES_LINE,R.mipmap.wx_scan_line)

.setLaserStyle(ScannerOptions.LaserStyle.RES_GRID, R.mipmap.zfb_grid_scan_line)//网格图
.setFrameCornerColor(0xFF26CEFF)//支付宝颜色
// .setLaserStyle(ScannerOptions.LaserStyle.RES_GRID, R.mipmap.zfb_grid_scan_line)//网格图
// .setFrameCornerColor(0xFF26CEFF)//支付宝颜色

.setScanFullScreen(true)
// .setScanFullScreen(true)

// .setFrameHide(false)
.setFrameCornerHide(false)
// .setFrameCornerHide(false)
// .setLaserMoveFullScreen(false)

.setViewfinderCallback(new ScannerOptions.ViewfinderCallback() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public enum LaserStyle {
private int laserLineHeight = DEFAULT_LASER_LINE_HEIGHT;//扫描线高度,网络样式无效,单位dp
private int laserLineMoveSpeed = 6;//扫描线移动间距,默认每毫秒移动6px,单位px
private boolean laserMoveFullScreen;//扫描线全屏移动,默认在扫描框内移动
private int frameStrokeColor = Color.WHITE;//扫描边框颜色rgb值
private float frameStrokeWidth = 1f;//扫描边框的宽度,单位px
private int frameWidth;//扫描框的宽度,单位dp
private int frameHeight;//扫描框的高度,单位dp
private int frameCornerColor = laserLineColor;//扫描框4角颜色rgb值
Expand Down Expand Up @@ -98,6 +100,14 @@ public boolean isLaserMoveFullScreen() {
return laserMoveFullScreen;
}

public int getFrameStrokeColor() {
return frameStrokeColor;
}

public float getFrameStrokeWidth() {
return frameStrokeWidth;
}

public int getFrameWidth() {
return frameWidth;
}
Expand Down Expand Up @@ -272,6 +282,28 @@ public Builder setLaserMoveFullScreen(boolean fullScreen) {
return this;
}

/**
* 扫描边框颜色值,默认白色
*
* @param color rgb颜色值
* @return
*/
public Builder setFrameStrokeColor(int color) {
options.frameStrokeColor = color;
return this;
}

/**
* 扫描边框宽度,默认1px
*
* @param width 单位px
* @return
*/
public Builder setFrameStrokeWidth(float width) {
options.frameStrokeWidth = width;
return this;
}

/**
* 设置扫描框大小
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
Expand Down Expand Up @@ -252,8 +251,8 @@ private void drawFrameCorner(Canvas canvas, Rect frame) {
* @param frame
*/
private void drawFrame(Canvas canvas, Rect frame) {
paint.setColor(Color.WHITE);//扫描边框白色
paint.setStrokeWidth(1);
paint.setColor(scannerOptions.getFrameStrokeColor());//扫描边框色
paint.setStrokeWidth(scannerOptions.getFrameStrokeWidth());
paint.setStyle(Paint.Style.STROKE);
canvas.drawRect(frame, paint);
}
Expand Down

0 comments on commit b3165e4

Please sign in to comment.