expo sdk :- 38
react-navigation": “^4.0.9”,
“react-navigation-tabs”: “^2.9.0”,
"Plaform: "Android"
您可以在tabbaroptions中尝试
keyboardHidesTabBar: true
Prebaesto
<Tab.Navigator
initialRouteName="Feed"
tabBarOptions={{
activeTintColor: '#e91e63',
keyboardHidesTabBar: true //<=====
}}
>
使用这个社区钩子(它将一定会起作用)
NPMinstall @react-native-native-community/hooks
键盘基础上的Rander键盘打开或不开放
import { Tabs } from "expo-router"; import { useKeyboard } from "@react-native-community/hooks"; export default function TabLayout() { const keyboard = useKeyboard(); return ( <Tabs initialRouteName="home" screenOptions={{ tabBarActiveTintColor: "white", tabBarInactiveTintColor: "white", tabBarShowLabel: false, tabBarStyle: keyboard.keyboardShown ? { display: "none" } // Hide tab bar when keyboard is open : { display: "flex", flexDirection: "row", alignItems: "center", }, }} > <Tabs.Screen name="home" options={{ title: "Home", headerShown: false, tabBarIcon: ({ focused }) => ( <TabIcon source={icons.home} focused={focused} /> ), }} /> </Tabs> ); }