Android Zxing修改二维码中扫描框的大小仿微信

在com.zxing.camera包中找到CameraManager.java

//修改这里最小最大值,限制扫描框大小 

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 (screenResolution == null)
            return null;
        if (framingRect == null) {
            if (camera == null) {
                return null;
            }

            //这样设置比微信扫描框稍微大点看着差不多
            int width = screenResolution.x * 2 / 3;
            int height = screenResolution.y * 2 / 4;

            if (height >= width) { //竖屏
                height = width;
            } else { //黑屏
                width = height;
            }

            int leftOffset = (screenResolution.x - width) / 2;
            int topOffset = (screenResolution.y - height) / 3;
            framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);

        }
        return framingRect;
    }

android Zxing实现扫描二维码条形码功能仿微信集成闪光灯生成二维码

你可能感兴趣的:(Android)