【发布时间】:2019-01-17 16:04:00
【问题描述】:
我遇到了 KeyboardAvoidingView 的问题,我有 3 个 TextInput,当我想在最后一个上写一些东西时,这个被我的键盘偷了。
export default class App extends React.Component {
render() {
return (
<LinearGradient colors={['#72afd3', '#37ecba']} style={styles.container}>
<KeyboardAvoidingView behavior='padding' enabled>
<TextInput placeholder='Hello World'/>
<View style={{height: 200}}/>
<TextInput placeholder='Hello World'/>
<View style={{height: 200}}/>
<TextInput placeholder='Hello World'/>
</KeyboardAvoidingView>
</LinearGradient>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
}
})
【问题讨论】:
-
你在安卓上看到这个问题了吗?
-
是的,我用安卓手机测试
-
如果您使用 expo,这可能会有所帮助。我有一个类似的问题,状态栏干扰了布局。我通过在 app.json 文件中指定状态栏设置来修复它。您可以在此处阅读如何执行此操作。 docs.expo.io/versions/latest/workflow/configuration#__next
标签: javascript node.js react-native