android - 在本机反应中打开相机而不是全屏
问题描述
我正在尝试在视图中打开相机,我已经设置了视图的高度和宽度,但它正在全屏打开。我用过react-native-camera
和react-native-image-crop-picker
图书馆。下面是我用来实现上面的代码:
rendercamera = () =>{
ImagePicker.openCamera({
width: width*0.5,
height: 400,
cropping: true,
}).then(image => {
console.log(image);
});
}
render() {
return (
<View style={styles.containers}>
<ScrollView>
<View style={styles.header}>
<TouchableOpacity onPress={this._goBack}>
<Image
style={styles.backicon}
source={images.backArrowAn}
/>
</TouchableOpacity>
<Text style={styles.headerText}>Add Id Card</Text>
<View style={styles.backicon}></View>
</View>
<View
style={{
width: width,
alignItems: "flex-end",
justifyContent: "center",
marginTop: height * 0.12,
alignSelf: "center",
alignItems: "flex-end"
}}
>
{this.rendercamera()}
</View>
</ScrollView>
</View>
);
}
任何人都可以帮忙吗?
解决方案
您的软件包 ImagePicker 没有这样做的能力。尝试使用react-native-camera
<RNCamera
ref={ref => {
this.camera = ref;
}}
style={{//Your style code
}}
type={RNCamera.Constants.Type.back}
flashMode={RNCamera.Constants.FlashMode.on}
androidCameraPermissionOptions={{
title: 'Permission to use camera',
message: 'We need your permission to use your camera',
buttonPositive: 'Ok',
buttonNegative: 'Cancel',
}}
androidRecordAudioPermissionOptions={{
title: 'Permission to use audio recording',
message: 'We need your permission to use your audio',
buttonPositive: 'Ok',
buttonNegative: 'Cancel',
}}
onGoogleVisionBarcodesDetected={({ barcodes }) => {
console.log(barcodes);
}}
/>
推荐阅读
- c++ - 如何转换类型擦除的 std::function?
- ios - UIStackView:我可以限制可以插入的视图以符合协议吗?
- javascript - 如何根据下拉列表选择从谷歌表格中获取信息?
- angularjs - 从一个表向另一个表添加和删除行 - AngularJS
- php - 中心的引导导航栏徽标和左侧和右侧的项目
- typescript - 用于自定义数组的 Typescript .find
- wpf - Layout Transform 改变控件的布局
- swiftui - SwiftUI 和具有 @Published 的组合 Observable 对象不断发布
- sharepoint - 如何在个人 Web 部件中显示过去 14 天内修改的项目?
- haskell - 使用列表理解的列表中连续数字的总和