expo: barCodeScanner cannot show in full screen in Android
🐛 Bug Report
Environment
Expokit 33.0.4 in Android(This issue not happen in iOS and work well in both iOS & Android in Expokit 32)
Steps to Reproduce
const styles = StyleSheet.create({
cameraContainer: {
flex: 1,
alignItems: 'center',
}
}
Inside the React component, it only renders the BarCodeScanner
<BarCodeScanner
onBarCodeScanned={!this.state.loading ? this._scanQRCodeToRedeem : () => {}}
barCodeTypes={[BarCodeScanner.Constants.BarCodeType.qr]}
style={[StyleSheet.absoluteFill, styles.cameraContainer]}
>
</BarCodeScanner>
Expected Behavior
barCodeScanner should show in full screen
Actual Behavior
barCodeScanner cannot show in full screen with two white area on the top and bottom

Snack Demo
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 16
- Comments: 32 (9 by maintainers)
Commits related to this issue
- Workaround for https://github.com/expo/expo/issues/5212 which doesn't allow Android fullscreen scanner. <Camera> Component has scanning inbuilt functionality. Added minimal design for the scanning pag... — committed to Bogdan-Florian/mobile-scan-and-shop by Bogdan-Florian 3 years ago
- Merged PR 22: Expo issue workaround and fetch methods modified to incorporate latest secure authentication changes - Workaround for https://github.com/expo/expo/issues/5212 which doesn't allow Androi... — committed to Bogdan-Florian/mobile-scan-and-shop by Bogdan-Florian 3 years ago
It seems that
<Camera>can actually read bar codes and it works just fine. If the camera is stretched, you can try changing the pixel ratio.@OscarYuen : I have solved my problem with a style wrapper and height attribute :
It works ! (but I still do not understand why ^^)
I got something! 🎉
you can make the camera scanner show in full screen(but zoomed) by adding width and height styles to 1000 for both but with proper frontend stylings, you can make it look filled in
<BarCodeScanner onBarCodeScanned={scanned ? undefined : this._handleBarCodeScanned} style={{ width: 1000, height: 1000 }} />
my expo versions “expo”: “~44.0.0”, “expo-barcode-scanner”: “~11.2.0”
As a rock-solid workaround I just went with a black background for a container (it’s applied only for problematic devices and looks natural):
Please re-open, the bug is still not fixed and switching to expo-camera doesn’t solve the problem of expo-bar-scanner. A PR must be done for closing it.
hey all! using expo-camera instead of expo-barcode-scanner is a good option, it gives you full control over the camera viewport. we’ll look into exposing a
resizeModeoption to expo-barcode-scanner at some point in the future.You could try the following code which is very similar to barCodeScanner component with same style applied.
maybe this can help someone, works on a lot of devices, basically just making the Camera larger than the screen and trying to center
try this,
it worked for me
styles:
Same issue here, but horizontally. I use native-base for components customization and Expo SDK 33 (updated from SDK 32). As you can see, I have a left and right extra padding 😦
Expo CLI 3.0.8 environment info: System: OS: Windows 7 Binaries: Node: 12.4.0 - G:\Travail\nodejs\node.EXE npm: 6.9.0 - G:\Travail\nodejs\npm.CMD
Here is my code :
I have tried
flex: 4and several attributes, absoluteFillObject does not work.Hi, any update on this?
I’m using @deepnothing’s fix, when are we going to have a real fix on expo-barcode-scanner?
@jp928 unfortunately that didn’t work me
I agree ticket should be reopened especially if it works in expo-camera
Note that its still not possible to “absoluteFill” the BarCodeScanner even in SDK38 - at least without workarounds. However its super easy to replace it with the Camera component which supports it (the only change I had to perform is to wrap the barCodeTypes property into a barCodeScannerSettings one).