【问题标题】:Getting zxing to run in portrait mode让 zxing 以纵向模式运行
【发布时间】:2018-01-23 18:23:16
【问题描述】:

我正在尝试使用 zxing 在我的应用程序中安装一个 qrcode 阅读器,而无需安装另一个应用程序。但无法使其纵向显示。

我已经在堆栈溢出和其他网站的负载中读到过这个问题,但在我的情况下问题仍然存在。

基本上每个人都说这是解决方案:

https://gist.github.com/border/7577978

但我唯一得到的是活动仍然是横向的,但是矩形现在更小(纵向尺寸)并且相机变得奇怪,因为图像旋转了 90 度并在我移动手机时向下移动向右移动手机时向左和向上。

有人说你需要删除支票:

    if    (width > height) {
  Log.i(TAG, "Display reports portrait orientation; assuming this is incorrect");
  int temp = width;
  width = height;
  height = temp;
}

在 CameraConfigurationManager.java 但该检查不再存在:

CameraConfigurationManager.java

【问题讨论】:

  • 你试过github.com/journeyapps/zxing-android-embedded吗?我正在使用它,这是一个完美的免费插件来扫描条形码
  • @MrNeo 我真的只想扫描二维码。我可以用那个插件来做,还是只适用于条形码?有没有设置教程?
  • 嗯,我正在使用它来扫描二维码和条形码。我会把我的项目更新到github,你可以试试
  • 解决了 zxing-android-embedded 的问题。非常感谢。

标签: android zxing


【解决方案1】:

试试这个

如果您正在使用此库(compile 'com.journeyapps:zxing-android-embedded:3.5.0'),只需将此行添加到您的 ma​​nifest 文件中二维码。

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

【讨论】:

  • 对我来说没有任何变化。但图书馆现在是 3.5.0
【解决方案2】:

您可以按照the link 中的说明在您的应用程序中设置 ZXing。如果没有,您可以将 ZXing 库下载到您的计算机中并将其添加到 libs 文件夹中。 之后,您可以在您的应用程序中以纵向模式使用 ZXing,或者使用 CompoundBarcodeView 将其设置为 layout

请参考my project。我正在使用 ZXing。希望对您有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-04
    相关资源
    最近更新 更多