我正在使用包含 View 的 react native 模式。 View 有一些 TextInput 元素。当键盘弹出时,View 元素全部折叠以适应剩余空间,但我根本不希望 View 发生变化。
对于 IOS,这不会发生。而且,它不会发生在同一应用中的 Android 非模态视图中。
我在我的 android Manifest 中设置了 windowSoftInputMode="adjustPan",但它似乎没有应用到 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 的 subview 使用固定高度值而不是 flex。 (使用尺寸高度得到它)。 它似乎按我的预期工作。
关于android - react native 模态,避免在打开键盘时调整 View 大小(Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49101955/