KeyboardAvoidingView not Working Properly

前端 未结 14 2296
悲&欢浪女
悲&欢浪女 2020-12-02 08:51

KeyboardAvoidingView not Working Properly

I am trying to use the KeyboardAvoidingView with behavior="padding".

For some reason, when I

14条回答
  •  攒了一身酷
    2020-12-02 09:38

    My issue was with the keyboardHidesTabBar option. The following setup worked for me:

    const AppBottomTabNavigator = createBottomTabNavigator(
      {
        ...
      },
      {
        tabBarOptions: {
          keyboardHidesTabBar: Platform.OS !== 'ios',
        },
      },
    );
    

    Component:

    import React from 'react';
    import {
      Keyboard,
      KeyboardAvoidingView,
      Platform,
      StyleSheet,
      Text,
      TextInput,
      TouchableWithoutFeedback,
      View,
    } from 'react-native';
    import { Header } from 'react-navigation-stack';
    
    const styles = StyleSheet.create({
      container: {
        flex: 1,
      },
      center: {
        justifyContent: 'center',
        alignItems: 'center',
      },
      textInput: {
        height: 40,
        borderColor: 'gray',
        borderWidth: 1,
      },
    });
    
    const MyScreen = () => {
      return (
        
          
            
              
                Hello!
              
              
            
          
        
      );
    };
    
    export default MyScreen;
    

提交回复
热议问题