我正在使用react-native Modal,其中包含一个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>
statusBarTranslucent={true}
应用
Modal
属性,以使模态内容不调整大小并且键盘平移模态内容。container: {
left: 50,
position: "absolute",
right: 50,
top: 50
}