如何使用 React Native 在默认键盘上方制作工具栏?

mal*_*ich 3 javascript android ios react-native

默认情况下,如何使用 React Native 在键盘上创建按钮?我的意思是本机键盘的按钮(不要更改键盘,只需添加上面的前缀) 在此处输入图像描述

K.W*_*.Wu 7

像这样使用KeyboardAvoidingView组件react-native

import React, { Component } from 'react';
import { View, Text, KeyboardAvoidingView, TextInput } from 'react-native';
import { Header } from 'react-native-elements';

class App extends Component {
    render() {
        return (
            <View style={{ flex: 1, backgroundColor: 'white' }}>
                <Header
                    outerContainerStyles={{ ... }}
                    centerComponent={(
                        <Text style={{ ... }}>
                            Test Screen
                        </Text>
                    )}
                />
                <View style={{ flex: 1 }}>
                    <TextInput
                        style={{ ... }}
                        value={ ... }
                        onChangeText={() => { }}
                    />
                </View>
                <KeyboardAvoidingView
                    behavior='padding'
                    style={{ backgroundColor: '#4099FF' }}
                >
                    <Text>
                        Toolbar
                    </Text>
                </KeyboardAvoidingView>
            </View>
        );
    }
}

export default App;
Run Code Online (Sandbox Code Playgroud)

然后你有这个:

在此处输入图片说明