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.

Header is always top padded in Android, even for non-translucent StatusBar

See original GitHub issue

Related to #1574

In Android, using the Header element, the top padding is always set to the statusbar’s height but that should only happen when the statusbar is translucent.

When the statusbar is translucent, the header is drawn under the statusbar and we need the top padding. When the statusbar is not translucent, the header is drawn right below the statusbar and thus, needs no top padding.

The issue is in the style config at: https://github.com/react-native-training/react-native-elements/blob/next/src/header/Header.js#L135

I think the calls to getStatusBarHeight() should be getStatusBarHeight(!StatusBar.translucent) so that we always get 0 for Android when the StatusBar is not translucent.

However, for some reason StatusBar.translucent is always undefined for me and that’s why I didn’t create a PR.

software version
react-native-elements next branch
react-native 0.57.4
npm or yarn yarn

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
tiagoalvescommented, Nov 30, 2018

If the fix would simply be to set paddingTop: 0, then I’d say that the issue should be closed, but as one can see in my fix, above, fixing it for a non-translucent statusbar actually requires having a deeper notion of the statusbar size differences in iOS and Android.

Would it make sense to force using the the existing statusBarProps prop to indicate whether the statusbar is translucent and thus use that prop to perform the right calculation? For instance:

<Header
  statusBarProps={{ translucent: true }}
  ...
/>

Regarding the theming feature, I’m just using it for some small visual tweaks to the Header element so I don’t have much feedback but it was easy to set up and I like the way one can centrally change the general theme. 👌

1reaction
lklimacommented, Oct 26, 2019

@tiagoalves você salvou meu dia mano.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expo (React Native): Statusbar is not showing on android and ...
I think the padding top is caused by this line paddingTop: Constants.statusBarHeight but I assume it won't be an issue anymore once the ......
Read more >
Hide the status bar - Android Developers
This lesson describes how to hide the status bar on different versions of Android. Hiding the status bar (and optionally, the navigation ...
Read more >
Configuring the status bar - Expo Documentation
This guide is intended to help you know what tools are at your disposal to configure the status bar for your iOS and...
Read more >
How to hide status bar on Android devices? - ManageEngine
Hiding the Android status bar is made easy with Mobile Device Manager Plus. Learn how to disable/hide the notification bar on Android devices...
Read more >
Why would I want to fitsSystemWindows? | by Ian Lake - Medium
Most of the time, your app won't need to draw under the status bar or the ... the android:fitsSystemWindows="true" attribute gives you: it...
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