如何减小QR码扫描仪的尺寸。
当我尝试应用样式道具时,它不起作用
在下面的代码中,我的扫描仪正在工作,但正在全屏显示,我必须减小其高度和宽度
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
TouchableOpacity,
Linking,
View,
} from 'react-native';
import { Dimensions } from "react-native";
const SCREEN_HEIGHT = Dimensions.get("window").height;
const SCREEN_WIDTH = Dimensions.get("window").width;
const scanBarWidth = SCREEN_WIDTH * 0.46;
import QRCodeScanner from 'react-native-qrcode-scanner';
export default class OpenTicket extends Component {
onSuccess(e) {
// console.log(e.data);
this.props.navigation.navigate('OpenApplianceIssue', {
data: e.data,
} );
}
render() {
return (
// this below scanner size I have to reduce
<QRCodeScanner style={{height: 50, width: 50,
borderRadius: 10}}
onRead={this.onSuccess.bind(this)}
cameraStyle={{ height: SCREEN_HEIGHT }}
cameraProps={{captureAudio: false}}
bottomContent={
<Text style={styles.buttonText}>SCAN ITEM</Text>
}
/>
);
}
}
const styles = StyleSheet.create({
centerText: {
flex: 1,
fontSize: 18,
padding: 32,
color: '#777',
},
textBold: {
fontWeight: '500',
color: '#000',
},
buttonText: {
fontSize: 21,
color: 'rgb(0,122,255)',
},
buttonTouchable: {
padding: 16,
},
});
///我已经附上了我正在使用的完整代码。 //谢谢..
答案 0 :(得分:0)
您可以将 cameraStyle 用于恒定高度而不是整个屏幕高度 这是我的工作道具:
containerStyle={{height:300}}
cameraStyle={[{height:300}]}