【发布时间】:2017-10-06 15:55:39
【问题描述】:
我很难让 KeyboardAvoidingView 正常工作。
我想将它包裹在 cmets 的 FlatList 和 TextInput 周围以添加新评论。当键盘处于活动状态时,两个元素都应该向上移动。如果你使用 Instagram,就像他们的 cmets 屏幕一样。
但是,无论我尝试什么,只有 TextInput 会向上移动,越过 cmets。
<View style={{ flex: 1 }}>
<KeyboardAvoidingView behavior="padding" keyboardVerticalOffset={65} style={{ flex: 1 }}>
<FlatList
style={{ flex: 1 }}
data={comments}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="always"
ref={commentList => {
this.commentList = commentList;
}}
keyExtractor={item => item.id}
renderItem={({ item }) => <CommentItem {...item} />}
/>
<CommentForm updateId={updateId} userId={userId} />
</KeyboardAvoidingView>
</View>
非常欢迎任何帮助。
我已经尝试了 Views 的组合并将 TextInput 添加为 Footer,但都不起作用。
【问题讨论】:
标签: react-native scrollview react-native-flatlist