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

Navbar window fitting android #485

Closed
tankers746 opened this issue Apr 29, 2020 · 7 comments
Closed

Navbar window fitting android #485

tankers746 opened this issue Apr 29, 2020 · 7 comments

Comments

@tankers746
Copy link

tankers746 commented Apr 29, 2020

I was wondering why the following was reverted:
4f8efd2

The current navbar on android doesn't take into account for using a translucent status bar:

MainActivity.onCreate

getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);

image

@janicduplessis
Copy link
Contributor

janicduplessis commented Apr 29, 2020

I'm using this patch as a workaround for now, we tried making it work properly before but ended up very difficult.

In ScreenStackHeaderConfig.java

@@ -153,6 +156,13 @@ public class ScreenStackHeaderConfig extends ViewGroup {
       getScreenFragment().setToolbar(mToolbar);
     }
 
+    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+      mToolbar.setPadding(0, getRootWindowInsets().getSystemWindowInsetTop(), 0, 0);
+    } else {
+      // Hacky fallback for old android.
+      mToolbar.setPadding(0, (int)(25 * getResources().getDisplayMetrics().density), 0, 0);
+    }
+
     activity.setSupportActionBar(mToolbar);
     ActionBar actionBar = activity.getSupportActionBar();

Maybe we could make it a prop so try to find some heuristic to figure out if we're drawing under the statusbar.

@hirbod
Copy link
Contributor

hirbod commented Apr 29, 2020

Well.. we both got the same error on the same day ;)
Was about to release my app right now. So we need to set translucent to false again and go with black for now...
So Expo -> translucent just dont work.

native-stack, native header.

Bildschirmfoto 2020-04-29 um 19 50 09

@mrousavy
Copy link

@janicduplessis Your patch doesn't work for me, it's saying "package Build does not exist". Where did you import the Build class from?

@mrousavy
Copy link

Nevermind, found it! If anyone's interested, I've created a patch for this. Use patch-package and rebuild to include the patch.

@WoLewicki
Copy link
Member

Can you check if #518 fixes your issue? It should apply proper insets for translucent/non translucent status bar.

@WoLewicki
Copy link
Member

I am closing it due to no response in more than 30 days. Also, #545 changed the behavior and should have fixed the issue. Feel free to comment to reopen it.

@hirbod
Copy link
Contributor

hirbod commented Jul 1, 2020

I can confirm that it was fixed in the latest release

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

5 participants