问题描述
我正在使用一个本机反应模态,其中包含一个View.该视图具有一些TextInput元素.当键盘弹出时,所有View元素都会折叠以适合剩余空间,但我根本不希望View发生更改.
I'm using a react-native Modal, which contains a View.The View has some TextInput elements. When the keyboard pops up, the View elements all collapse to fit into the remaining space, but I don't want the View to change at all.
IOS不会不发生这种情况.而且,它不会不会在同一应用程序中的Android非模式视图中发生.
This does not happen for IOS. And also, it does not happen in non-modal Views for Android within the same app.
我在Android清单中设置了windowSoftInputMode ="adjustPan",但它似乎未应用于Modal.
I have windowSoftInputMode="adjustPan" set in my android Manifest, but it doesn't seem to be applied on the Modal.
return(
<ImageBackground source={require('./../images/IMG1.png')}
style={{flex: 1}} imageStyle={{resizeMode: 'cover'}}>
<View style={{flex: 1}}>
(...)
<Modal visible={this.state.modalVisible} animationType={'slide'}
presentationStyle={'fullScreen'}
onRequestClose={() => this.closeModal()}>
<ImageBackground source={require('./../images/IMG2.png')}
style={{flex: 1}} imageStyle={{resizeMode: 'cover'}}>
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
<View style={{flex:1}}>
(...)
<View style={{flex:0.9, alignItems:'center', justifyContent: 'center',
flexDirection: 'row'}}>
<TextInput style={MyStyle.textInput}
onChangeText={(myTitle) => this.setState({myTitle})}
placeholder='Title'
/>
</View>
推荐答案
作为一种解决方法,我最终为Modal的子视图使用了固定的高度值,而不是使用flex. (使用尺寸高度进行匹配).它似乎按我的预期工作.
As a workaround, I ended up using a fixed height value for the Modal’s child View instead of flex. (Got it using Dimensions height).It seems to work as I expected.
这篇关于响应本机Modal,避免在打开键盘时调整视图的大小(Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!