Original: Android Project Combat (44): zxing Two-dimensional code switching horizontal screen scanning
Demo Link
The default is portrait scanning, but when we configure the horizontal screen display in the manifest file:
<activity android:name=". Captureactivity" android:screenorientation="landscape" android:theme="@android: Style/theme.notitlebar.fullscreen" / >
This time scan, you will find that the scanning effect deformation, the direction is wrong.
You can modify it by following these steps:
1, modify the setdesiredcameraparameters function in Cameraconfigurationmanager.java ,
Camera.setdisplayorientation (90); ---> camera.setdisplayorientation (0);
2. Modify Cameramanager.java 's getframingrectinpreview () function to change to the following, change x to Y, y to X
Rect.left = Rect.left * cameraresolution.x/ screenresolution.x; = Rect.right * cameraresolution.x/ screenresolution.x; = Rect.top * CAMERARESOLUTION.Y/ screenresolution.y; = Rect.bottom * CAMERARESOLUTION.Y/ screenresolution.y;
3, modify the decode function in Decodehandler.java
4. Other modifiable parts refer to GitHub Demo
Can be set: the width of the middle line in the scan box in the middle line of the scan box and the gap between the left and right of the scan box, the distance between each of the four green corner corresponding to the length, width, color, transparency, the top position of the middle sliding line, the lowest-end position scan line is a picture occlusion layer color, The color of the area outside the square flash point color Other features: Flash on the local get picture read QR code current XXX Time no scan, close the current scan QR code interface
Android Project Combat (44): zxing QR code switching horizontal screen scanning