Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transparent background for header using createStackNavigator, React Native

Tags:

I created a project using CRNA that uses React-Navigation. In one of the screen I have a background image that cover the entire screen and I want to including the header.

Like this image :

enter image description here

Should I just hide the header and use a View that contains the element that I want? If yes will this cause any trouble in case of deep linking?

Solution

React Navigation offers a cool props called headerTransparent that can be used in order to render something under the header.

So the code at the should look like this :

static navigationOptions = {     headerTransparent: true   } 
like image 399
t97 Avatar asked Sep 23 '18 19:09

t97


People also ask

How do you make the background of a header transparent?

The option to Enable Transparent Header can be found in Appearance > Customize > Header. Once that option is selected, a new option will appear to Show Transparent Header on the Homepage Only.

What is headertransparent in React React navigation?

React Navigation offers a cool props called headerTransparent that can be used in order to render something under the header. when i set headerTransparent=true , my back button in header is not working..you have any solution regarding this. Can you share your code? and remember is headerTransparent : true not headerTransparent = true!

How to make the beneath view visible in React Native?

There is one value which the backgroundColor supports which is transparent. Using the transparent value we can easily set any View component background to Transparent which will make the Beneath View visible. This type of designing is mostly used to make the view overlap in react native applications.

Is @react-navigation/native-stack a performance issue?

This may not be an issue for a lot of apps, but if you're experiencing performance issues during navigation, consider using @react-navigation/native-stack instead - which uses native navigation primitives.

How to display custom image in the back button in react?

headerBackImage Function which returns a React Element to display custom image in header's back button. When a function is used, it receives the tintColor in it's argument object. Defaults to Image component with back image source, which is the default back icon image for the platform (a chevron on iOS and an arrow on Android).


1 Answers

Right now with React Navigation 5 we can do something like this:

{     headerShown: true,     headerTransparent: true, } 

For example:

const Screen = ({ navigation }) => {   navigation.setOptions({     headerShown: true,     headerTransparent: true,   });    return (     <View>       <Text>Render your component</Text>     </View>   ); }; 
like image 57
abranhe Avatar answered Oct 04 '22 22:10

abranhe