我使用的是RN-0.61.5,我遇到了一个奇怪的问题,即当我切换到软件键盘时,FlatList上方的所有内容都将移出屏幕。我使用了KeyboardAvoidingView,它将除textInput之外的所有元素保留在屏幕中。文本输入被发送到视图之外。Original content without keyboard和keyboard popped up
我无法弄清楚该如何避免键盘将我的textInput条推出屏幕。以下是textInput搜索条形码。任何帮助表示赞赏。
const searchBar = (
<KeyboardAvoidingView
style={{
flex: 1,
flexDirection: 'row',
position: 'relative',
justifyContent: 'flex-start',
}}
behavior={Platform.OS === IOS ? 'position' : undefined}
keyboardVerticalOffset={550}
>
<View style={styles.searchBarContainer}>
<Card style={styles.searchBar}>
<TextInput
style={styles.inputSearch}
placeholder={I18n.t('ResourcesList.searchResourcePlaceholder')}
onChangeText={text => {
props.updateQuery(text);
}}
onSubmitEditing={props.submitSearch}
clearButtonMode="always"
/>
{props.loading ? (
<View style={styles.searchBarPlaceholder}>
{PlaceholderLoaderSmall('')}
</View>
) : (
<></>
)}
<TouchableOpacity activeOpacity={0.5} onPress={props.submitSearch}>
<Image source={props.imageSource} style={styles.searchButton} />
</TouchableOpacity>
</Card>
</View>
</KeyboardAvoidingView>
);