Android項目實戰(四十四):Zxing二維碼切換橫屏掃描

來源:互聯網
上載者:User

標籤:blank   cap   nta   r.java   技術   github   otto   rac   cape   

原文:Android項目實戰(四十四):Zxing二維碼切換橫屏掃描

Demo連結

預設是豎屏掃描,但是當我們在資訊清單檔中配置橫屏顯示的時候:

  <activity            android:name=".CaptureActivity"            android:screenOrientation="landscape"            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />

這時候掃描,會發現掃描效果變形,方向不對。

 

可按以下步驟進行修改:

1、修改CameraConfigurationManager.java中的setDesiredCameraParameters函數,

      camera.setDisplayOrientation(90);   --->    camera.setDisplayOrientation(0);

     

 

2、修改CameraManager.javagetFramingRectInPreview()函數中修改成如下,即將x改為y  , y改為x

rect.left = rect.left * cameraResolution.x / screenResolution.x;  rect.right = rect.right * cameraResolution.x /  screenResolution.x;  rect.top = rect.top * cameraResolution.y / screenResolution.y;  rect.bottom = rect.bottom * cameraResolution.y /  screenResolution.y;  

 

3、修改DecodeHandler.java中的decode函數

 

4、其它可修改部分參照Github Demo 

可設定的:掃描框中的中間線的寬度掃描框中的中間線的與掃描框左右的間隙中間那條線每次重新整理移動的距離四個綠色邊角對應的長度 、 寬度、顏色 、透明度中間滑動線的最頂端位置 、 最低端位置掃描線  是一張圖片遮擋層顏色 , 正方形之外的 地區的顏色閃點顏色其他功能:閃光燈開啟從本地擷取圖片讀取二維碼當前xxx時間內沒有掃描 , 關閉當前掃描二維碼介面

 

Android項目實戰(四十四):Zxing二維碼切換橫屏掃描

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.