Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insets.top changed during render on Android with <Statusbar translucent={true} /> #61

Closed
wong2 opened this issue Mar 6, 2020 · 4 comments

Comments

@wong2
Copy link

wong2 commented Mar 6, 2020

const insets = useSafeArea()

return (
  <Layout>
    <Statusbar translucent={true} />
    <Content />
  </Layout>
)

insets.top will change during render(from 0 to the right value), which makes my element position jump

@satya164
Copy link
Collaborator

satya164 commented Mar 6, 2020

You are making the statusbar translucent in render, so it's going to happen after the component mounts which will then trigger event with new size. It seems expected. You need to set translucent statusbar in your native theme to avoid this.

@satya164 satya164 closed this as completed Mar 6, 2020
@wong2
Copy link
Author

wong2 commented Mar 13, 2020

What do you mean by native theme?

1 similar comment
@lumberman
Copy link

What do you mean by native theme?

@davidgovea
Copy link

davidgovea commented Sep 2, 2020

@wong2 @lumberman 'native theme' means setting the values in XML using android theme values (edit: or programattically in java app code, I suppose)

see: https://developer.android.com/reference/android/R.attr#windowTranslucentStatus

In my case, I specified this behavior in android/app/src/main/res/values/styles.xml:

<resources>
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    ...
        <item name="android:windowTranslucentStatus">true</item> <!-- Added this -->

With this style, content extends under the statusbar, and the safe area insets properly include the status bar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants