android - 如何在 react-native 中将 TextInput 附加到键盘

标签 android ios keyboard react-native


我正在使用 react-native 构建一个针对 iOS 和 Android 的应用程序。
其中一件事是有一个连接到键盘的文本输入。
它的工作方式是 TextInput 位于屏幕底部。当它被触摸时 - 键盘打开并且文本输入以相同的速度(因为它们连接在一起)与键盘一起向上或向下动画。
现在,我使用 onKeyboardWillShowonKeyboardWillHide 并为 TextInput 设置动画。问题是它没有以相同的速度移动。
基本上,我正在尝试这样做:
https://github.com/Just-/UIViewController-KeyboardAnimation
任何建议都会有所帮助。

最佳答案

使用react native的keyboard avoiding view KeyboardAvoidingViewExample 喜欢

import {ScrollView, Text, TextInput, View, KeyboardAvoidingView} from "react-native";

并在渲染函数中嵌套 ViewTextInput

<KeyboardAvoidingView behavior='padding'>
  <View style={styles.textInputContainer}>
    <TextInput
      value={this.state.data}
      style={styles.textInput}
      onChangeText={this.handleChangeData}
    />
  </View>
</KeyboardAvoidingView>

它会解决这个问题

关于android - 如何在 react-native 中将 TextInput 附加到键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34779394/

相关文章:

java - 无法找到})的含义; Android 中的大括号、圆括号

android - 如何从 Android 设备发送 icmpv6 路由器广告消息

ios - 如果用户已经使用 facebook 登录,则使用 swift 调用 segue

java - 关注 JpopupMenu 时检测键盘输入 (Java)

Android - 如何让开关变大?

android - 尽管有 rawResponse,errorBody() 在 Retrofit2 中返回 null

windows - 关闭 F 锁的功能键的键码?

ios - 如何降低键盘高度

ios - 当用户点击 SwiftUI 中的列表行时如何显示警报

ios - 忽略 NSArray 上的对象 - 内存管理器