[英]Keyboard doesn't show with KeyboardAvoidingView in React Native
I would like to know how can I use the keyboard with React Native. 我想知道如何在React Native上使用键盘。
When I click in my input (on "Send"), I don't have a Keyboard show. 当我单击输入时(在“发送”上),没有键盘显示。
I tried to use "KeyboardAvoidingView" but the Keyboard doesn't show. 我尝试使用“ KeyboardAvoidingView”,但键盘未显示。
ChatScreen.js
ChatScreen.js
import React from 'react';
import { ScrollView, KeyboardAvoidingView, StyleSheet, Text, View } from 'react-native';
import MessageList from './MessageList';
import MessageForm from './MessageForm';
export default class ChatScreen extends React.Component {
render() {
return (
<KeyboardAvoidingView style={styles.container} behavior="padding" enabled>
<MessageList />
<MessageForm />
</KeyboardAvoidingView>
);
}
}
const styles = StyleSheet.create({
container: {
display: 'flex',
flexDirection: 'column',
flexGrow: 1,
backgroundColor: 'grey',
alignSelf: 'stretch',
},
});
MessageForm.js
MessageForm.js
import React from 'react';
import { StyleSheet, Text, View, TextInput } from 'react-native';
import MessageFormStyles from './MessageFormStyles'
export default class MessageForm extends React.Component {
render() {
return (
<View style={MessageFormStyles.container}>
<TextInput
style={MessageFormStyles.input}
placeholder="Send">
</TextInput>
</View>
);
}
}
Package.json
的package.json
"dependencies": {
"axios": "0.19.0",
"expo": "31.0.2",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-gesture-handler": "^1.3.0",
"react-native-vector-icons": "^6.6.0",
"react-navigation": "3.11.1",
"react-redux": "6.0.1",
"redux": "4.0.4",
"redux-devtools-extension": "2.13.8",
"redux-immutable-state-invariant": "^2.1.0",
"redux-thunk": "^2.3.0"
},
Do you have an idea why I don't see the Keyboard ? 您知道为什么我看不到键盘吗?
If you are using a simulator then the keyboard must be disabled in your simulator hardware settings. 如果您使用的是模拟器,则必须在模拟器的硬件设置中禁用键盘。
Please go and toggle the keyboard and you might see the keyboard again 请转到并切换键盘,您可能会再次看到键盘
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.