反映原生模态,避免在打开键盘时调整视图大小(Android)

我正在使用一个包含View的反应原生模态.
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的子视图而不是flex的固定高度值. (使用尺寸高度获得).
它似乎按我的预期工作.

上一篇:linux – 有什么理由让我得到^ [[当我在控制台登录界面按下箭头时?


下一篇:IE9和10无法反映javascript光标更改