【发布时间】:2019-06-30 01:29:17
【问题描述】:
我正在使用 react-native TextInput 组件。如果用户点击 textInput 字段,这里我需要在键盘上方显示 InputBox。
我在下面尝试过,但我遇到了问题
1.键盘避免视图
a. Here it shows some empty space below the input box
b. Manually I need to scroll up the screen to see the input field which I was given in the text field
c. Input box section is hiding while placing the mouse inside the input box
2。 react-native-Keyboard-aware-scroll-view
a.It shows some empty space below the input box
b.ScrollView is reset to the top of the page after I moving to the next input box
这里我在 ScrollView 组件中设置了 Keyboard-aware-scroll-view
请澄清
我的示例代码是
<SafeAreaView>
<KeyboardAvoidingView>
<ScrollView>
<Text>Name</Text>
<AutoTags
//required
suggestions={this.state.suggestedName}
handleAddition={this.handleAddition}
handleDelete={this.handleDelete}
multiline={true}
placeholder="TYPE IN"
blurOnSubmit={true}
style= {styles.style}
/>
</ScrollView>
</KeyboardAvoidingView>
</SafeAreaView>
[https://github.com/APSL/react-native-keyboard-aware-scroll-view]
【问题讨论】:
-
尝试为 KeyboardAvoidingView 设置 behviour,并确保您的 contianer 视图样式为 flex
-
我为 KeyboardAvoidingView 设置了 behavior = 'padding' style = {{flex:1 }}。
NAME placeholder="TYPE IN"/> -
我在 react native 中需要这种类似的行为。移动到文本输入框时,键盘打开并在返回后关闭。github.com/Just-/UIViewController-KeyboardAnimation
-
你能试着去掉
<View>标签,在<KeyboardAvoidingView>外面放一个吗? -
不知道你为什么回滚我的编辑。如果您可以将代码放在问题描述中,那肯定会有所帮助。
标签: react-native textbox keyboard-events textinput