Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How make the toolbar above default keyboard with React Native?

How can I make a button over the keyboard by default using React Native? I mean the buttons for the Native keyboard (do not change the keyboard, just add as the prefix above)

enter image description here

like image 778
malyarevich Avatar asked Jan 28 '23 15:01

malyarevich


1 Answers

Use KeyboardAvoidingView component from react-native like this

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;

Then you have this:

enter image description here

like image 157
K.Wu Avatar answered Jan 31 '23 07:01

K.Wu