question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[native-stack] Header is out of the safe area on Android

See original GitHub issue

Moved from react-navigation/react-navigation#6797. Originally opened by @enheit


Current Behavior

The header navigation is rendered beyond safe area on Android devices.

image

Expected Behavior

The header should be rendered in ‘safe area’.

image

(this is how @react-navigation/stack works)

How to reproduce

Create a screen by using Screen.Stack from @react-navigation/native-stack

Your Environment

software version
iOS or Android Android (v9)
@react-navigation/native ^5.0.0-alpha.33
@react-navigation/native-stack ^5.0.0
react-native-screens ^2.0.0-beta.2
react-native ~0.61.4
expo ~36.0.0
node v12.14.1
npm or yarn 6.13.4

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Erc93commented, Apr 3, 2020

@WoLewicki I just realised that I might be running into a separate but similar issue. I seem to be getting the problem when using import { createNativeStackNavigator } from "react-native-screens/native-stack"; to create my stack. Using the stack navigator from react-navigation seems to fix my issue.

Here is an example: https://snack.expo.io/HqDtTeyzQ

1reaction
dougg0kcommented, Jun 15, 2020

I found a temp solution for Android while using Expo. In the Screen options, when declaring your header (left, center and right), you can add height and marginTop to it and that can help, maybe not in all cases though.

headerCenter: (props) => (
    <Text
      style={{
        color: "white",
        fontSize: 18,
        height: 40,
        marginTop: 30,
      }}
    >
      Title
    </Text>
  ),
Read more comments on GitHub >

github_iconTop Results From Across the Web

[native-stack] Header is out of the safe area on Android ...
When setting StatusBar translucent to true, header will get render out of safe area on android. StatusBar translucent=true StatusBar ...
Read more >
Supporting safe areas
React Navigation handles safe area in the default header. However, if you're using a custom header, it's important to ensure your UI is...
Read more >
Navigating Between Screens
This native-stack navigator uses the native APIs: UINavigationController on iOS and Fragment on Android so that navigation built with ...
Read more >
A guide to React Native Navigation
In this guide, learn how to enable different types of navigation in your React Native apps by building an example e-commerce application.
Read more >
react-navigation header has a faint line
While this question seems to be targeted at android, the answers also mention ... const styles = StyleSheet.create ({ safeArea : { flex:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found