简体   繁体   English

在React Native中键盘不与KeyboardAvoidingView一起显示

[英]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.

相关问题 使用 KeyboardAvoidingView 作为父级反应 Native ViewPager 不会保持键盘向上 - iOS - React Native ViewPager with a KeyboardAvoidingView as parent doesn't keep the keyboard up - iOS 键盘在React Native中使用Scrollview和KeyboardAvoidingView阻止文本输入 - Keyboard blocking textinput with Scrollview and KeyboardAvoidingView in react native keyboardAvoidingView keyboard React 本机代码中未删除顶部空格 - keyboardAvoidingView keyboard Top white space is not removed in React native code 反应本机 KeyboardAvoidingView 未正确移动 - React native KeyboardAvoidingView not moving correctly React-Native - KeyboardAvoidingView - 错误 - React-Native - KeyboardAvoidingView - Error React Native:图像未显示在视图中 - React Native: Image doesn't show in the view React Native Modal 不显示动画 - React Native Modal doesn't show animations React Native 键盘显示但似乎无法检测输入(Android) - React Native Keyboard Shows But Doesn't Appear to Detect Input (Android) 带有ScrollView的KeyboardAvoidingView在react-native或expo中不起作用 - KeyboardAvoidingView with ScrollView are Not working in react-native or expo KeyboardAvoidingView 在我的代码中不起作用 - 反应原生 - KeyboardAvoidingView is not working in my code -react native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM