反应导航底部导航在焦点输入上显示一个灰色框

时间:2020-03-18 12:49:11

标签: react-native coding-style react-native-android react-navigation

当我专注于输入时,我的底部导航存在问题

how i can solve that ?

当我专注于该输入字段的底部导航时,将其隐藏起来,但之前是灰色框。

我想知道如何删除该框

const TabBarComponent = props => <BottomTabBar {...props} />;

  {
    initialRouteName: "showFlow",
    tabBarComponent: props => (
      <TabBarComponent {...props} style={styles.bottomNav} />
    ),
    tabBarOptions: {
      inactiveTintColor: colors.grey,
      activeTintColor: colors.background1
    }
  }

2 个答案:

答案 0 :(得分:0)

尝试将keyboardHidesTabBarhttps://reactnavigation.org/docs/bottom-tab-navigator#tabbaroptions设置为false

答案 1 :(得分:0)

最后,我确实找到了解决该问题的方法:

import { Keyboard } from "react-native";
const TabBarComponent = props => {
    const [show, setShow] = useState(false);

    useEffect(() => {
      let keyboardDidShowListener = Keyboard.addListener(
        "keyboardDidShow",
        _keyboardDidShow
      );

      let keyboardDidHideListener = Keyboard.addListener(
        "keyboardDidHide",
        _keyboardDidHide
      );

      return () => {
        keyboardDidShowListener.remove();
        keyboardDidHideListener.remove();
      };
    }, []);

  const _keyboardDidHide = () => setShow(false);
  const _keyboardDidShow = () => setShow(true);

  return (
    <BottomTabBar
      {...props}
      style={{ height: show ? 0 : 80, backgroundColor: colors.background1 }}
    />
  );
};