赞
踩
I've MainActivity.kt where I show different fragments for different needs. At some point, I press button 'X' that calls startScanner() function:
private fun startScanner() {
IntentIntegrator(this)
.setOrientationLocked(false)
.setPrompt("SCANNING?")
.initiateScan()
}
Manifest.xml:
android:name=".MainActiity"
android:theme="@style/AppTheme"
tools:replace="android:screenOrientation"
android:stateNotNeeded="true"
android:screenOrientation="fullSensor"
android:windowSoftInputMode="stateHidden" />
Gradle.file:
compile 'com.journeyapps:zxing-android-embedded:3.6.0'
It does open scanner and everything, but in landscape mode.
Why is this not working?
解决方案
There is a shortcut to do this. Just add this to the manifest:
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="portrait"
tools:replace="android:screenOrientation"
android:stateNotNeeded="true"/>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。