2

I want to add image behind the header but how can I do that ? I have made header transparent but now I want to place the image below it (See screenshot 1). I also tried to add position: 'absolute' and top,bottom,left,right for image but it doesn't work why so ?

Code:

screen: ProjectDetailsScreen,
        navigationOptions: ({ navigation }) => ({
            headerStyle: {
                backgroundColor: 'transparent'
            },
            headerTitle: navigation.state.params.title,
        }),

Screenshot 1:

enter image description here

1
  • 1
    brother please try my solution! Commented Jan 4, 2019 at 7:26

2 Answers 2

6

Try using the mix of zIndex and Position in styles !

like in the manner of this!

1: make the header as

screen: ProjectDetailsScreen,
    navigationOptions: ({ navigation }) => ({
        headerStyle: {
            position:'relative',
            zIndex: 1
        },
      headerTransparent: true
    })
    // this will cause header on the top and make the rest of design in below part
     lowerViewContainerStyle:{
            position:'absolute',
            zIndex: 0
     }
Sign up to request clarification or add additional context in comments.

3 Comments

If I try to add top, left, right, bottom, position: 'absolute' inside headerStyles it gives warning saying it has no effect on headerStyles so it is not working. So headerTransparent: true works fine.
the position and zIndex help to put the image behind the header and also the lower header on top index!
Can you please help me here: stackoverflow.com/questions/54132013/…
1

Adding headerTransparent: true inside navigationOptions solved the problem.

Code:

navigationOptions: ({ navigation }) => ({    
      headerTransparent: true
})

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.