react-native-qrcode-scanner icon indicating copy to clipboard operation
react-native-qrcode-scanner copied to clipboard

Change Size Preview Camera

Open huytran123 opened this issue 6 years ago • 7 comments

image

I want to change preview size camera like that. But i set width and height Camera and View contain Camera view. They are not working well,

Please help me how to change them

Thanks HuyTran

huytran123 avatar Nov 15 '18 04:11 huytran123

Do something like this:

<QRCodeScanner
            onRead={this.onSuccess.bind(this)}
            ref={(node) => { this.scanner = node; }}
            containerStyle={{ marginTop: 10 }}
            cameraStyle={{ height: 200, marginTop: 20, width: 200, alignSelf: 'center', justifyContent: 'center' }}
          />

cerberusv2px avatar Dec 18 '18 15:12 cerberusv2px

Hi guys, I there any way to have the camera's preview screen to fit width of main container ? Thanks

porzioj avatar Jan 04 '19 22:01 porzioj

Hi guys, I there any way to have the camera's preview screen to fit width of main container ? Thanks

Isn't it by default?

cerberusv2px avatar Jan 05 '19 10:01 cerberusv2px

With the following code I expect my preview to fit screen's width size by default

<QRCodeScanner containerStyle={{ borderColor: 'red', borderWidth: 5 }} cameraStyle={{ borderColor: 'green', borderWidth: 5 }} />

But I don't even see the border color...

screenshot 2019-01-05 at 12 52 42

Did I missed something ?

porzioj avatar Jan 05 '19 15:01 porzioj

@porzioj try giving width of QRCodeScanner as const borderwidth = 5

width: Dimensions.get('screen').width - ( borderwidth * 2 ) borderWidth: borderwidth

GaneshSaiKumar avatar Jan 10 '19 19:01 GaneshSaiKumar

Got the same issue and solved it successfully I've explained it at #173, feel free to check it and hopefully it's helpful for your case.

howieyoung avatar Feb 15 '19 18:02 howieyoung

Hi guys, I there any way to have the camera's preview screen to fit width of main container ? Thanks

Setting cameraStyle width to 100% seems to have worked for me.

  cameraStyle: {
    alignSelf: 'center',
    justifyContent: 'center',
    width: '100%',
  }

noumantahir avatar Feb 28 '22 05:02 noumantahir