I'm trying to place an input on bottom of the screen and when I click, I want it to be above the keyboard. I'm using Expo. I have tried two scenarios:
screenOptions={{
tabBarHideOnKeyboard: 'true'
}}
configuration in tab bar but it does not work smoothly and it also will not work if I try to add custom component for the bottom tab bar.
Here is my code:
NewComp.js:
const NewComp = () => {
return (
<KeyboardAvoidingView
behavior={"height"}
style={{ flex: 1 }}
>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<View style={{
padding: 24,
flex: 1,
justifyContent: "flex-end"
}}>
<TextInput placeholder="Username" style={{
height: 40,
borderColor: "#000000",
borderBottomWidth: 1,
}}/>
</View>
</TouchableWithoutFeedback>
</KeyboardAvoidingView>
);
};
BottomNavigator.js:
const BottomNavigator = ({ navigation, route }) => {
return (
<Tab.Navigator>
<Tab.Screen key={1} name={'TAB_1'} component={NewComp} options={{header: () => null}}/>
<Tab.Screen key={2} name={'TAB_2'} component={NewComp} options={{header: () => null}} />
<Tab.Screen key={3} name={'TAB_3'} component={NewComp} options={{header: () => null}} />
</Tab.Navigator>
);
}
have you tried this doc KeyboardAvoidingView ? I can set whether the position of the content will be above the keyboard or behind.
if you want to display, send props enabled={true} this is the default value. if you want to hide, send props enabled={false}