在com.zxing.camera包中找到
//修改这里最小最大值,限制扫描框大小
private static final int MIN_FRAME_WIDTH = 240;//240
private static final int MIN_FRAME_HEIGHT = 240;//240
private static final int MAX_FRAME_WIDTH = 480;//480
private static final int MAX_FRAME_HEIGHT = 480;//360
CameraManager类的getFramingRect方法
public Rect getFramingRect() {
Point screenResolution = configManager.getScreenResolution();
if (framingRect == null) {
if (camera == null) {
return null;
}
int width = screenResolution.x * 2 / 3;//设定框框宽度大小
if (width < MIN_FRAME_WIDTH) {
width = MIN_FRAME_WIDTH;
} else if (width > MAX_FRAME_WIDTH) {
width = MAX_FRAME_WIDTH;
}
int height = screenResolution.y * 2/ 4;//设定框框高度大小
if (height < MIN_FRAME_HEIGHT) {
height = MIN_FRAME_HEIGHT;
} else if (height > MAX_FRAME_HEIGHT) {
height = MAX_FRAME_HEIGHT;
}
int leftOffset = (screenResolution.x - width) / 2;//设定框框离左边相对位置
int topOffset = (screenResolution.y - height) / 5;//设定框框离顶部相对位置
framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
Log.d(TAG, "Calculated framing rect: " + framingRect);
}
return framingRect;
}