在键入TextInput React Antial(EXPO)时查看降低自身

发布于 2025-01-26 17:18:45 字数 2454 浏览 2 评论 0原文

通常,布局看起来不错,内容包裹在键盘上的视图中,如下所示:

<KeyboardAvoidingView
                   keyboardVerticalOffset={-useHeaderHeight()}
                   behavior={"padding"}
                   style={styles.container}>
                   <View style={styles.conversationContainer}>
                       <ScrollView
                           ref={scrollViewRef}
                           onContentSizeChange={() => scrollViewRef.current.scrollToEnd({ animated: true })}
                           overScrollMode='never'
                           showsVerticalScrollIndicator={false}
                           enableOnAndroid={true}
                           style={styles.conversation}>
                           {messagesView}
                       </ScrollView>
                       <View
                           style={styles.send}>
                           <TextInput
                               value={text}
                               textAlignVertical='center'
                               placeholder='Write your message'
                               style={styles.textInput}
                               blurOnSubmit={true}
                               onChangeText={(value) => setText(value)}
                           >
                           </TextInput>
                           <TouchableOpacity
                               style={[styles.button]}
                               activeOpacity={.6}
                               onPress={() => addMessage()}>
                               <IonIcon
                                   name={"arrow-forward-circle-outline"}
                                   size={30}
                                   color={'#00966E'}
                                   style={styles.icon} />
                           </TouchableOpacity>
                       </View>
                   </View>
               </KeyboardAvoidingView>

在打开键盘时,文本输入按预期将其放置在键盘上方。

键盘图片

但是,每当我按下单个击键时,整个视图(包括textInput)向下,覆盖文本的一半。

覆盖TextInput的键盘

图像对于不同的值以及将行为更改为“ heigth” “位置” none 。这些都没有改变任何事情。

In general the lay-out seems fine, the content is wrapped up inside a KeyboardAvoidingView as followed:

<KeyboardAvoidingView
                   keyboardVerticalOffset={-useHeaderHeight()}
                   behavior={"padding"}
                   style={styles.container}>
                   <View style={styles.conversationContainer}>
                       <ScrollView
                           ref={scrollViewRef}
                           onContentSizeChange={() => scrollViewRef.current.scrollToEnd({ animated: true })}
                           overScrollMode='never'
                           showsVerticalScrollIndicator={false}
                           enableOnAndroid={true}
                           style={styles.conversation}>
                           {messagesView}
                       </ScrollView>
                       <View
                           style={styles.send}>
                           <TextInput
                               value={text}
                               textAlignVertical='center'
                               placeholder='Write your message'
                               style={styles.textInput}
                               blurOnSubmit={true}
                               onChangeText={(value) => setText(value)}
                           >
                           </TextInput>
                           <TouchableOpacity
                               style={[styles.button]}
                               activeOpacity={.6}
                               onPress={() => addMessage()}>
                               <IonIcon
                                   name={"arrow-forward-circle-outline"}
                                   size={30}
                                   color={'#00966E'}
                                   style={styles.icon} />
                           </TouchableOpacity>
                       </View>
                   </View>
               </KeyboardAvoidingView>

With the keyboard open, the TextInput is placed above the keyboard as intended.

Keyboard Picture

But whenever I press a single keystroke, the entire view (including the TextInput), lowers down, covering half of the TextInput.

Image of keyboard covering the TextInput

I have already tried changing the KeyboardVerticalOffset to different values as well as the changing the behavior to "heigth", "position" or none. None of these happened to change anything.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぽ尐不点ル 2025-02-02 17:18:45

也有同样的问题。此语法对我有帮助:&lt; keyboardAvoidingView
行为= {platform.os ==='ios'? '填充':“高度”}&gt;

Had the same issue. This syntax helped me: <KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文