2015-10-15 161 views
2

我試圖在我的應用程序中獲取qrcode閱讀器,而無需安裝其他應用程序,使用zxing。但不能用肖像來表現。讓zxing在肖像模式下運行

我已經讀過關於堆棧溢出和其他網站的負載,但問題仍然存在於我的案例中。

基本上大家都說這是解決方案:

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

+1

您是否嘗試過https://github.com/journeyapps/zxing-android-embedded?我正在使用它,這是一個完美的免費插件掃描條碼 –

+0

@MrNeo我真的只想掃描QR碼。我可以使用該插件嗎,還是僅適用於條形碼?有沒有關於如何設置它的任何教程? –

+0

嗯,我用這個掃描QR碼和條形碼。我會將我的項目更新到github,你可以試試 –

回答

1

你可以按照指令在the link到在您的應用程序中設置ZXing。如果沒有,您可以將ZXing庫下載到您的計算機中並將其添加到libs文件夾中。 之後,您可以在肖像模式下在您的應用中使用ZXing,或使用CompoundBarcodeView將其設置爲layout

請參考my project。我正在使用ZXing。希望這個幫助!

2

嘗試這個

只是如果你使用這個庫(編譯「com.journeyapps:斑馬線,Android的嵌入式:3.5.0」)這行添加到您的清單文件QR碼。

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