在 Android Studio 中使用 ZXING 更改 QR 扫描仪方向

2024-02-05

我希望你能帮我解决这个问题。我使用 Zxing 嵌入式库来使用 QR 扫描仪,问题是处于横向模式,我想将其更改为纵向。

我的 Gradle 依赖项中有这个

compile 'com.journeyapps:zxing-android-embedded:2.0.1@aar'
compile 'com.journeyapps:zxing-android-integration:2.0.1@aar'
compile 'com.google.zxing:core:3.0.1'

我在我的java类中有这个可以用按钮激活扫描仪......

public void scanQR(View view){
    IntentIntegrator integrator = new IntentIntegrator(this);
    integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE_TYPES);
    integrator.setResultDisplayDuration(0);//Text..
    integrator.setPrompt(" Scan a QR Code");
    integrator.setScanningRectangle(450, 450);//size
    integrator.setCameraId(0);  // Use a specific camera of the device
    integrator.initiateScan();

}

谢谢您的帮助!


无需扩展类,只需将其添加到清单中即可:

  <activity
            android:name="com.journeyapps.barcodescanner.CaptureActivity"
            android:screenOrientation="portrait"
            tools:replace="android:screenOrientation"
            android:stateNotNeeded="true"/>

奇迹般有效

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Android Studio 中使用 ZXING 更改 QR 扫描仪方向 的相关文章

随机推荐