大佬教程收集整理的这篇文章主要介绍了反应本机键盘关闭不起作用,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
谁能解释一下为什么键盘关闭不起作用?没有错误,也没有任何反应。
在我的上一个项目中它有效,但不存在。我做错了什么?
import React,{ useState,useEffect } from 'react';
import { StyleSheet,VIEw,Text,TexTinput,touchabLeopacity,KeyboardAvoIDingVIEw,ScrollVIEw,Dimensions,Keyboard } from 'react-native';
import { AntDesign } from '@expo/vector-icons';
import { linearGradIEnt } from 'expo-linear-gradIEnt';
const wIDth = Dimensions.get('window').wIDth;
const height = Dimensions.get('window').height;
const Home = () => {
const [searchinput,setSearchinput] = useState('');
return (
<KeyboardAvoIDingVIEw onPress={() => Keyboard.dismiss()} style={styles.container}>
<linearGradIEnt
style={styles.header}
colors={['blue','red','orange']}
>
<VIEw style={{alignItems: 'flex-end'}}>
<touchabLeopacity>
<AntDesign style={{textAlign: 'right'}} name="pluscircLeo" size={42} color="#fff" />
</touchabLeopacity>
</VIEw>
<VIEw style={styles.headerBottom}>
<Text style={styles.headerText}>Treffpunkt</Text>
<TexTinput
placeholder="Gebe deinen Code ein"
value={searchinput}
onChangeText={value => setSearchinput(value)}
style={styles.searchinput}
/>
</VIEw>
</linearGradIEnt>
</KeyboardAvoIDingVIEw>
)
};
正如康斯坦丁在评论中提到的,KeyboardAvoidingView
没有 onPress
事件。
你可以在渐变之前有一个子元素来为你处理压力。
<KeyboardAvoidingView
style={styles.container}>
<TouchableWithoutFeedBACk onPress={() => Keyboard.dismiss()}>
<LinearGradient
style={styles.header}
colors={['blue','red','orange']}>
<View style={{ alignItems: 'flex-end' }}>
...
</View>
</LinearGradient>
</TouchableWithoutFeedBACk>
</KeyboardAvoidingView>
以上是大佬教程为你收集整理的反应本机键盘关闭不起作用全部内容,希望文章能够帮你解决反应本机键盘关闭不起作用所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。