Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle the SafeArea's background color with Bottom Tab Navigation?

Current Behavior

Hi everyone,

I want to set the background color for the Bottom Tab. So I did as below.

<Tab.Navigator
      tabBarOptions={{
        activeTintColor: '#FF0000',
        activeBackgroundColor: '#FFFFFF',
        inactiveBackgroundColor: '#FF0000',
        inactiveTintColor:  '#FFFFFF'
      }}>
      <Tab.Screen
        name="Home"
        component={HomeScreen}
      />
      <Tab.Screen
        name="Account"
        component={AccountScreen}
      />
    </Tab.Navigator>

https://user-images.githubusercontent.com/6939811/76062160-b6dfde00-5fb7-11ea-8808-3f2562e90c24.png

The problem is the SafeArea has a white background

Expected Behavior

What I expect is https://user-images.githubusercontent.com/6939811/76062716-cca1d300-5fb8-11ea-926a-acbd42d412dd.png

So could you tell me how to solve this issue in React Navigation version 5 please? Thank you!

Your Environment

iOS react-native: 0.61.5

@react-navigation/native: ^5.0.5

@react-navigation/bottom-tabs: ^5.0.5

like image 206
Danh Nguyen Avatar asked Mar 06 '20 09:03

Danh Nguyen


People also ask

What is bottom tab navigation?

Bottom tabs refers to a row of links, displayed at the bottom of the screen, and is referred to as "Tab Bar" in iOS and as "Bottom Navigation Bar" on Android. Usually these are intended to be used to switch between top-level content views with a single tap.

Where do I put SafeAreaView?

import { SafeAreaView } from 'react-native'; You just use it in place of the top-level View component. It makes sure content within the safe area boundaries is properly rendered around the nested content and applies padding automatically.


1 Answers

I just set backgroundColor

<Tab.Navigator
    initialRouteName="Stack_Main"
    tabBarOptions={{
      style: {
        backgroundColor: "#FF0000",
      },
    }}
  >
like image 119
amir hossein hayati Avatar answered Nov 15 '22 08:11

amir hossein hayati