Mat*_*ete 5 camera android qr-code orientation zxing
我希望你能帮助我.我使用Zxing嵌入式库来使用QR扫描仪,问题是在横向模式下,我想将其更改为纵向.
我在Graddle的依赖项上有这个
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'
Run Code Online (Sandbox Code Playgroud)
我在我的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();
}
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助!
小智 23
不要扩展类,只需将其添加到清单:
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait"
tools:replace="android:screenOrientation"
android:stateNotNeeded="true"/>
Run Code Online (Sandbox Code Playgroud)
奇迹般有效
NOT*_*MER 17
我在用
编译'com.journeyapps:zxing-android-embedded:3.1.0@aar'
这是不同的版本,所以我不知道这是否适合你,但这对我有用.
更多关于我的设置,我只编译
'com.journeyapps:斑马线,Android的嵌入式:3.1.0@aar'
'com.google.zxing:核心:3.0.1'
我没有编译
'com.journeyapps:斑马线,Android的整合:2.0.1@aar'
首先,我从CaptureActivity创建了一个活动扩展
或单击此链接查看课程https://gist.github.com/TheGratefulDev/21a557c9a96333ec037c
public class CaptureActivityPortrait extends CaptureActivity {
//Nothing in side.
}
Run Code Online (Sandbox Code Playgroud)
其次,加上这个
integrator.setCaptureActivity(CaptureActivityPortait.class);
进入您的集成商代码.
这就是我的样子:
CustomIntegrator integrator = new CustomIntegrator(activity);
integrator.setDesiredBarcodeFormats(CustomIntegrator.PDF_417);
integrator.setPrompt("Scan a barcode");
integrator.setCameraId(0); // Use a specific camera of the device
integrator.setOrientationLocked(true);
integrator.setBeepEnabled(true);
integrator.setCaptureActivity(CaptureActivityPortrait.class);
integrator.initiateScan();
Run Code Online (Sandbox Code Playgroud)
最后,在AndroidMaifest添加
Run Code Online (Sandbox Code Playgroud)<activity android:name=".custom.CaptureActivityPortrait" android:screenOrientation="portrait" <---this is the most important line android:stateNotNeeded="true" android:theme="@style/zxing_CaptureTheme" android:windowSoftInputMode="stateAlwaysHidden"> </activity>
| 归档时间: |
|
| 查看次数: |
18020 次 |
| 最近记录: |