Javascript 如何在React Native中隐藏底部操作栏
我在React Native中有一个问题,我想隐藏底部的操作栏,它就在我的选项卡栏导航的下方 我想制作一个迪士尼+应用程序克隆,但这件事让我难以接受: 这是我的应用程序底部的小动作栏 没有此操作栏的原始应用程序 我不知道怎么做。 以下是我的App.js代码:Javascript 如何在React Native中隐藏底部操作栏,javascript,android,reactjs,react-native,react-navigation,Javascript,Android,Reactjs,React Native,React Navigation,我在React Native中有一个问题,我想隐藏底部的操作栏,它就在我的选项卡栏导航的下方 我想制作一个迪士尼+应用程序克隆,但这件事让我难以接受: 这是我的应用程序底部的小动作栏 没有此操作栏的原始应用程序 我不知道怎么做。 以下是我的App.js代码: import { StatusBar } from 'expo-status-bar'; import React from 'react'; import { NavigationContainer } from '@react-na
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Ionicons } from '@expo/vector-icons';
import HomeScreen from './screens/HomeScreen';
import SearchScreen from './screens/SearchScreen';
import DownloadScreen from './screens/DownloadScreen';
import ProfilScreen from './screens/ProfilScreen';
import { iconSize, prefix, activeTabColor, inactiveTabColor, tabBarBackgroundColor, appTheme } from './utils/Constants';
import { ImageBackground } from 'react-native';
import DisneyImageBackground from './assets/home-background.png';
const Tab = createBottomTabNavigator();
export default function App() {
const getTabColor = (focused) => {
return focused ? activeTabColor : inactiveTabColor;
}
const getScreenOptions = (route) => {
}
return (
<ImageBackground source={DisneyImageBackground} style={{ flex: 1 }} resizeMode="cover">
<NavigationContainer theme={appTheme}>
<Tab.Navigator
screenOptions={
({ route }) => ({
tabBarIcon: ({ focused }) => {
if (route.name === 'Home') {
return <Ionicons name={`${prefix}-home`} color={getTabColor(focused)} size={iconSize} />
} else if (route.name === 'Search') {
return <Ionicons name={`${prefix}-search`} color={getTabColor(focused)} size={iconSize} />
} else if (route.name === 'Download') {
return <Ionicons name={`${prefix}-download`} color={getTabColor(focused)} size={iconSize} />
} else if (route.name === 'Profil') {
return <Ionicons name={`${prefix}-person`} color={getTabColor(focused)} size={iconSize} />
}
},
})
}
tabBarOptions={{
activeBackgroundColor: tabBarBackgroundColor,
inactiveBackgroundColor: tabBarBackgroundColor,
showLabel: false,
style: {
height: 55,
borderTopWidth: 0.2,
borderTopColor: '#2f313d'
}
}}>
<Tab.Screen name='Home' component={HomeScreen} />
<Tab.Screen name='Search' component={SearchScreen} />
<Tab.Screen name='Download' component={DownloadScreen} />
<Tab.Screen name='Profil' component={ProfilScreen} />
</Tab.Navigator>
</NavigationContainer>
</ImageBackground>
);
}
从“世博会状态栏”导入{StatusBar};
从“React”导入React;
从'@react-navigation/native'导入{NavigationContainer};
从“@react navigation/bottom tabs”导入{createBottomTabNavigator};
从“@expo/vector icons”导入{Ionicons};
从“./屏幕/主屏幕”导入主屏幕;
从“./screens/SearchScreen”导入SearchScreen;
从“./screens/DownloadScreen”导入DownloadScreen;
从“/screens/ProfilScreen”导入ProfilScreen;
从“/utils/Constants”导入{iconSize,prefix,activeTabColor,inactiveTabColor,tabBarBackgroundColor,appTheme};
从“react native”导入{ImageBackground};
从“./assets/home background.png”导入DisneyImageBackground;
const Tab=createBottomTabNavigator();
导出默认函数App(){
const getTabColor=(聚焦)=>{
返回聚焦?activeTabColor:inactiveTabColor;
}
常量getScreenOptions=(路由)=>{
}
返回(
({
tabBarIcon:({focused})=>{
如果(route.name==='Home'){
返回
}else if(route.name==='Search'){
返回
}else if(route.name==“下载”){
返回
}else if(route.name==“profile”){
返回
}
},
})
}
禁忌选项={{
activeBackgroundColor:TabbackgroundColor,
inactiveBackgroundColor:TabbackgroundColor,
showLabel:false,
风格:{
身高:55,
borderTopWidth:0.2,
borderTopColor:“#2f313d”
}
}}>
);
}
如果有人能找到解决方案,那将非常有帮助:)
谢谢这是我的代码
App.js
import React, {useRef, useState, useEffect} from 'react';
import {
FlatList,
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
Image,
TouchableOpacity,
TextInput,
} from 'react-native';
import Home from './routes';
import {createAppContainer} from 'react-navigation';
const AppRoot = createAppContainer(Home);
class App extends React.Component {
constructor(props) {
super(props);
this._navigator = null;
}
render() {
alert('HI');
return <AppRoot />;
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'red',
justifyContent: 'center',
alignItems: 'center',
},
});
export default App;
import React,{useRef,useState,useffect}来自'React';
进口{
平面列表,
安全区域视图,
滚动视图,
状态栏,
样式表,
文本,
使用颜色方案,
看法
形象,,
可触摸不透明度,
文本输入,
}从“反应本机”;
从“/routes”导入主页;
从“react navigation”导入{createAppContainer};
const approt=createAppContainer(主);
类应用程序扩展了React.Component{
建造师(道具){
超级(道具);
这是。_navigator=null;
}
render(){
警报(“HI”);
return我不确定我是否明白你的意思。但是你想要的是删除底部的白色区域,对吗?它被称为安全区域,你可以阅读文档来处理它。@Micfong是的,就是这样。我想删除安全区域。感谢文档首先避免使用安全区域。是的,你将获得状态栏区域的上边距。。。使用SafeArea,但它也会添加marginBottom,使ActionBar可见
import React from 'react';
import {
StyleSheet,
View,
Text,
} from 'react-native';
import {createStackNavigator} from 'react-navigation-stack';
import {createBottomTabNavigator} from 'react-navigation-tabs';
import Profile from './Profile';
const NotifyNavigation = createStackNavigator(
{
Profile: {
screen: Profile,
navigationOptions: {
gesturesEnabled: false,
},
},
},
{
initialRouteName: 'Profile',
defaultNavigationOptions: {
headerTitleStyle: {
},
},
},
);
NotifyNavigation.navigationOptions = ({navigation}) => {
let {routeName} = navigation.state.routes[navigation.state.index];
let navigationOptions = {};
navigationOptions.tabBarVisible = routeName === 'Profile';
return navigationOptions;
};
const ProfileNavigation = createStackNavigator(
{
Profile: {
screen: Profile,
navigationOptions: {
gesturesEnabled: false,
},
},
},
{
defaultNavigationOptions: {
headerTitleStyle: {
// fontFamily: 'SFProText-Regular',
},
},
},
);
ProfileNavigation.navigationOptions = ({navigation}) => {
let {routeName} = navigation.state.routes[navigation.state.index];
let navigationOptions = {};
navigationOptions.tabBarVisible = routeName === 'Profile';
return navigationOptions;
};
const ScheduleNavigation = createStackNavigator(
{
Profile: {
screen: Profile,
navigationOptions: {
gesturesEnabled: false,
},
},
},
{
defaultNavigationOptions: {
headerTitleStyle: {
// fontFamily: 'SFProText-Regular',
},
},
},
);
ScheduleNavigation.navigationOptions = ({navigation}) => {
let {routeName} = navigation.state.routes[navigation.state.index];
let navigationOptions = {};
navigationOptions.tabBarVisible = routeName === 'Profile';
return navigationOptions;
};
/**
* TabNavigation
*/
const TabNavigation = createBottomTabNavigator(
{
CalenderTab: {
screen: ScheduleNavigation,
navigationOptions: {
tabBarIcon: ({focused}) => {
return (
<View style={styles.iconContainer}>
<Text style={{color: 'white'}}>User</Text>
</View>
);
},
},
},
NotifyTab: {
screen: NotifyNavigation,
navigationOptions: {
tabBarIcon: ({focused}) => {
return (
<View style={styles.iconContainer}>
<Text style={{color: 'white'}}>Movies</Text>
</View>
);
},
},
},
ProfileTab: {
screen: ProfileNavigation,
navigationOptions: {
tabBarIcon: ({focused}) => {
return (
<View style={styles.iconContainer}>
<Text style={{color: 'white'}}>Series</Text>
</View>
);
},
},
},
},
{
initialRouteName: 'ProfileTab',
navigationOptions: {
gesturesEnabled: false,
},
tabBarOptions: {
showLabel: false,
style: {
paddingTop: 5,
backgroundColor: 'black',
borderTopColor: '#e7e7e7',
borderTopWidth: 2,
height: 65,
},
},
},
);
/**
* Application Root
*/
const Root = createStackNavigator(
{
Main: TabNavigation,
},
{
headerMode: 'none',
mode: 'modal',
navigationOptions: {
gesturesEnabled: false,
},
},
);
// const AppContainer = createAppContainer(Root);
export default Root;
const styles = StyleSheet.create({
iconContainer: {
borderWidth: 1,
borderColor: 'red',
width: 50,
height: 50,
justifyContent: 'center',
alignItems: 'center',
},
});
import React from 'react';
import {View, Text} from 'react-native';
export default class Profile extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<View
style={{
flex: 1,
backgroundColor: '#ddd',
justifyContent: 'center',
alignItems: 'center',
}}>
<Text>Screen</Text>
</View>
);
}
}