我正在使用 react-native 构建一个针对 iOS 和 Android 的应用程序。
其中一件事是有一个连接到键盘的文本输入。
它的工作方式是 TextInput 位于屏幕底部。当它被触摸时 - 键盘打开并且文本输入以相同的速度(因为它们连接在一起)与键盘一起向上或向下动画。
现在,我使用 onKeyboardWillShow
和 onKeyboardWillHide
并为 TextInput 设置动画。问题是它没有以相同的速度移动。
基本上,我正在尝试这样做:
https://github.com/Just-/UIViewController-KeyboardAnimation
任何建议都会有所帮助。
最佳答案
使用react native的keyboard avoiding view KeyboardAvoidingView和 Example 喜欢
import {ScrollView, Text, TextInput, View, KeyboardAvoidingView} from "react-native";
并在渲染函数中嵌套 View
和 TextInput
<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/