android - react native 模态,避免在打开键盘时调整 View 大小(Android)

标签 android react-native view keyboard modal-dialog

我正在使用包含 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/

相关文章:

javascript - React Native列表页脚组件不起作用

android - 如何为自定义 Android 通知向 RemoteView 添加垂直线?

android - Android 应用程序的 Activity 和 View 设置 - 我应该为每个页面创建新 Activity 吗?

Android 浏览器和背面可见性问题

android - 更改 RowsSupportFragment 上的填充

android - 使用 React Native 创建原生 SDK

swift - 我应该如何将数据从 xib 发送到 viewcontroller?

java - 在模拟器中运行时,TextView 在自定义对话框中不可见

android - 从 Activity 上下文外部调用 startActivity()

javascript - 添加屏幕路线,而不是在主导航器中